Next.js Discord

Discord Forum

Why is Next.js trying to fetch from 127.0.0.1:44961?

Answered
Saltwater Crocodile posted this in #help-forum
Open in Discord
Avatar
Saltwater CrocodileOP
I manage a self-hosted Next.js installation, version 13.4.19. Today I found it had crashed, with the following stacktrace:

TypeError: fetch failed
    at Object.fetch (./node_modules/next/dist/compiled/undici/index.js:1:26669)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async invokeRequest (./node_modules/next/dist/server/lib/server-ipc/invoke-request.js:17:12)
    at async invokeRender (./node_modules/next/dist/server/lib/router-server.js:254:29)
    at async requestHandler (./node_modules/next/dist/server/lib/router-server.js:475:24)
    at async Server.<anonymous> (./node_modules/next/dist/server/lib/start-server.js:117:13) {
  cause: Error: connect ECONNREFUSED 127.0.0.1:44961
      at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1278:16) {
    errno: -111,
    code: 'ECONNREFUSED',
    syscall: 'connect',
    address: '127.0.0.1',
    port: 44961
  }
}

Restarting Next.js restored web application to a working condition.

Can someone come up with some wild guesses as to what exactly is going on here? Why was it trying to connect to 127.0.0.1:44961? This is supposed to be a static site, so it should definitely not attempt to fetch remote data.
Answered by joulev
This is a known bug, downgrade to 13.4.12
View full answer

8 Replies

Avatar
Asian black bear
next start seems to spawn extra processes now which describe themselves as render workers
next-router-worker
next-render-worker-app
next-render-worker-pages
They seem to listen to TCP ports to communicate?
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.1:37957         0.0.0.0:*               LISTEN      33709/next-render-w 
tcp        0      0 127.0.0.1:41689         0.0.0.0:*               LISTEN      33703/next-render-w 
Ok, here is the wild guess. One of those worker processes crashed, and when the core part of next start tried to connect it also crashed because the connection failed.
@Saltwater Crocodile ^
Avatar
This is a known bug, downgrade to 13.4.12
Answer
Avatar
(I also see some scattered reports of it working in canary, so maybe try upgrading to latest canary too)
Avatar
Saltwater CrocodileOP
Thanks @joulev it seems 13.4.12 is the sweet spot.

I was already holding it back to that version in other projects because of other critical bugs in higher versions (e.g. https://github.com/vercel/next.js/issues/54325).