N
Nuxt5mo ago
Jox

Timeout waiting for port

Trying to create a first e2e test in our project, and am getting GetPortError: Timeout waiting for port 59684 after 20 retries with 500ms interval when I run the test. The test itself is fairly simple.
import { $fetch, setup } from '@nuxt/test-utils/e2e'
import { describe, expect, it } from 'vitest'

describe('Index page', async () => {
await setup()

it('should render', async () => {
const html = await $fetch('/')
expect(html).toContain('something')
})
})
import { $fetch, setup } from '@nuxt/test-utils/e2e'
import { describe, expect, it } from 'vitest'

describe('Index page', async () => {
await setup()

it('should render', async () => {
const html = await $fetch('/')
expect(html).toContain('something')
})
})
I haven't been able to find helpful information online. Has anyone ran into this issue before?
8 Replies
kapa.ai
kapa.ai5mo ago
Hi @Jox. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The error GetPortError: Timeout waiting for port ... when running your Nuxt end-to-end test usually means that the test runner is unable to start or connect to the Nuxt development server within the expected time frame. This can happen if the server takes too long to start, if there is a port conflict, or if something is preventing the server from starting at all. Based on the official Nuxt documentation, here are some things to check and try: 1. Increase the setup timeout:
By default, the setup function allows 60 seconds (60000ms) for the Nuxt app to start. If your app takes longer, you can increase this with the setupTimeout option:
await setup({
setupTimeout: 120000, // 2 minutes
})

await setup({
setupTimeout: 120000, // 2 minutes
})

2. Check for port conflicts:
If another process is using the port Nuxt tries to use, you can specify a different port in the setup options:
await setup({
port: 3001, // or any free port
})

await setup({
port: 3001, // or any free port
})

3. Check your Nuxt app configuration:
Make sure your Nuxt app can start normally outside of the test environment. Try running nuxi dev or nuxi build && nuxi preview to see if there are any errors. 4. Target an existing host:
If you already have a Nuxt server running, you can point your tests to it using the host option:
await setup({
host: '<http://localhost:3000',>
})

await setup({
host: '<http://localhost:3000',>
})

5. Review test structure:
Ensure your test file is structured as shown in the docs, with setup called at the top level of the describe block and awaited properly. Your example matches the recommended structure, so this is likely not the issue, but double-check for typos or async issues. For more details and examples, see the Nuxt Testing documentation. If after these steps the issue persists, there may be a deeper configuration or environment problem. The knowledge sources do not provide a more specific solution for this error, so if these suggestions do not resolve it, consider checking for logs or errors when starting your Nuxt app, or try running a minimal test in a fresh Nuxt project to isolate the cause. Testing: Setup ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai5mo ago
<@525765413322227742> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
AGill
AGill3mo ago
@kapa.ai I tried the suggestions I still get the error "GetPortError: Timeout waiting for port 49450 after 20 retries with 500ms interval." What else can I do?
kapa.ai
kapa.ai3mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- If you have already tried increasing the setupTimeout, specifying a different port, and targeting an existing host but still encounter the error GetPortError: Timeout waiting for port ..., the knowledge sources do not provide a definitive solution beyond these steps. However, based on the official Nuxt documentation, here are the main supported troubleshooting steps: - Increase setupTimeout:
Make sure you are setting a sufficiently high value for setupTimeout in your setup call, as the default is 120,000ms (or 240,000ms on Windows) and can be increased if needed. - Specify a different port:
You can try explicitly setting a different port in the setup options to avoid conflicts. - Use the host option:
If you have a Nuxt server running separately, you can point your tests to it using the host option. - Check your Nuxt app:
Ensure your Nuxt app starts correctly outside of the test environment. If these steps do not resolve the issue, the knowledge sources do not provide further troubleshooting guidance for this specific error. You may need to investigate your local environment for issues such as firewall restrictions, lingering processes, or other system-specific problems that could prevent the test runner from acquiring a port or starting the server. If you continue to experience this problem, consider creating a minimal reproduction and reporting it to the Nuxt team, as suggested in the documentation and related GitHub issues. The documentation does not mention any additional solutions for this error at this time End-To-End Testing: Setup. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3mo ago
<@508382519146709018> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
AGill
AGill3mo ago
@Jox did you manage to figure this out?
Jox
JoxOP3mo ago
I did not unfortunately
AGill
AGill3mo ago
Yeah me neither. Did find a discussion: https://github.com/nuxt/nuxt/discussions/25204
GitHub
How should I add test to my application? · nuxt nuxt · Discussion...
Environment Operating System: Linux Node Version: v20.11.0 Nuxt Version: 3.9.1 CLI Version: 3.10.0 Nitro Version: 2.8.1 Package Manager: pnpm@8.14.1 Builder: - User Config: app, modules, css, ui, n...

Did you find this page helpful?