提问人:pa1 提问时间:9/3/2023 最后编辑:pa1 更新时间:9/3/2023 访问量:200
使用 IP 和端口启动 Next.js DEV 服务器时发现 getaddrinfo ENOTFOUND
getaddrinfo ENOTFOUND when starting Next.js DEV server with IP and port
问:
每当我尝试在LAN(192.168.1.7:3000)中运行开发服务器(无论是Vite,NextJS应用程序还是live-server)时,我总是收到此错误。
我在 Windows 上工作,我以前在我的 PC 中运行过 LAN 中的开发服务器。但是有些事情发生了变化,但我对此一无所知。 还有其他人遇到过这个问题吗?
我尝试了在NextJS(在网络上)上运行开发服务器时给出的答案,以用于我目前正在构建的下一个js应用程序,但仍然没有运气。 尝试手动运行服务器的结果:
npx next dev -- -H 192.168.1.7:3000
- error Failed to start server
Error: getaddrinfo ENOTFOUND 192.168.1.7:3000
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: '192.168.1.7:3000'
按照此答案中的建议在特定端口上手动运行。
npx next dev -- -H 192.168.1.7 -p 3000
- ready started server on 192.168.1.7:3000, url: http://192.168.1.7:3000
- event compiled client and server successfully in 219 ms (20 modules)
- wait compiling...
- event compiled client and server successfully in 168 ms (20 modules)
浏览器中的错误仍然占主导地位。
更新
我发现这个问题只出现在 Edge 中。该网站在 Chrome 中运行良好。这可能是什么原因?
答:
0赞
Brad
9/3/2023
#1
指定该选项时,必须仅指定主机,而不能指定主机和端口。-H
请改用 来指定绑定主机和端口。-H 192.168.1.7 -p 3000
Смотритетакже: https://nextjs.org/docs/app/api-reference/next-cli
评论
0赞
pa1
9/3/2023
我也试过这个。仍然没有奏效,错误仍然盛行
评论