1

Whenever I try to run a dev server (be it Vite, or a NextJS application, or live-server) in LAN (192.168.1.7:3000 like so), I always get this error.

Screenshot of error as shown in the browser

I am working on Windows and I have run dev servers in LAN before in my PC. But something has changed but I have no clue about it. Has anyone else faced this issue?

I tried the answers given in running a Development server on NextJS (on the network) for a next js application that I'm building at the moment, but still no luck. Result from trying to run the server manually:

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'

Running manually on specific port as suggested in this answer.

 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)

Error in the browser still prevailed.

Update

I found out that this issue arises only in Edge. The site is working completely fine in Chrome. What could be the reason for this?

pa1
  • 11
  • 1
  • 2

1 Answers1

0

When you specify the -H option, you must specify the host only, not the host and the port.

Use -H 192.168.1.7 -p 3000 instead, to specify the bind host and port.

See also: https://nextjs.org/docs/app/api-reference/next-cli

Brad
  • 159,648
  • 54
  • 349
  • 530