nuxt: Cannot start nuxt: Unable to obtain an available random port number!
Environment
- Operating System:
MacOS - Node Version:
v16.14.0 - Nuxt Version:
Nuxt 3.3.2 with Nitro 2.3.2 - Package Manager:
yarn@1.22.10 - Builder:
vite - User Config:
- - Runtime Modules:
- - Build Modules:
-
Reproduction
Create a nuxt project yarn yarn dev
Describe the bug
Nuxi 3.3.2
Nuxt 3.3.2 with Nitro 2.3.2
Local: http://localhost:3000/ Network: http://192.168.2.122:3000/
ERROR Cannot start nuxt: Unable to obtain an available random port number!
at getRandomPort (node_modules/get-port-please/dist/index.mjs:154:11)
at async findPort (node_modules/get-port-please/dist/index.mjs:238:24)
at async getPort (node_modules/get-port-please/dist/index.mjs:137:21)
at async listen (node_modules/listhen/dist/index.mjs:377:16)
at async node_modules/@nuxt/content/dist/module.mjs:519:31
at async initNitro (node_modules/nuxt/dist/index.mjs:2080:3)
at async initNuxt (node_modules/nuxt/dist/index.mjs:2503:3)
at async load (node_modules/nuxi/dist/chunks/dev.mjs:6824:9)
at async Object.invoke (node_modules/nuxi/dist/chunks/dev.mjs:6874:5)
at async _main (node_modules/nuxi/dist/cli.mjs:49:20)
Additional context
No response
Logs
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 20 (8 by maintainers)
I was able to solve this issue by removing
NUXT_HOST="http://localhost:8080"from .env filesThe same issue.
Description: I think it’s a system problem. But the configuration has not changed, there have been no updates. Both old versions and a fresh installation from scratch suddenly stopped working. I have already tried disabling the firewall, extinguishing background processes, using different versions of npm and node.
PORT=3000 npm run devandnuxt dev --port 3000results to the same error.Thanks for the reports. It seems the issue is commonly related to invalid or occupied
HOST.I think we can improve this upstream with fallback host support ~> https://github.com/unjs/get-port-please/issues/57
Also PR welcome to improve error with explicit host (https://github.com/unjs/get-port-please/issues/58)
cc: @pi0
I have same system. Solution for me in redefinition
NUXT_HOSTvariable:NUXT_HOST="127.0.0.1" yarn devorNUXT_HOST="" yarn devIt seems like this is due to explicit overriding of the host rather than an issue in Nuxt itself.
However, I think we likely should update the error message in this case as it is a little confusing.