N
Nuxt3mo 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?
2 Replies
kapa.ai
kapa.ai3mo 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.ai3mo ago
<@525765413322227742> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?