Skip to content

Commit

Permalink
Use 127.0.0.1 as the default host for the standalone server (#52283)
Browse files Browse the repository at this point in the history
This helps getting rid of the

```
Error: connect ECONNREFUSED ::1:64696
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16) {
  errno: -61,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '::1',
  port: 64696
}
```

error for me when running the standalone server. cc @ijjk.

I'm not sure if it's related to http-party/node-http-proxy#835.

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
  • Loading branch information
shuding and ijjk authored Jul 5, 2023
1 parent 31dee6f commit 267c2d2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/next/src/server/lib/render-server-standalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ export const createServerHandler = async ({
didInitialize = true

const getProxyServer = (pathname: string) => {
const targetUrl = `http://${hostname}:${routerPort}${pathname}`
const targetUrl = `http://${
hostname === 'localhost' ? '127.0.0.1' : hostname
}:${routerPort}${pathname}`
const proxyServer = httpProxy.createProxy({
target: targetUrl,
changeOrigin: false,
Expand Down

0 comments on commit 267c2d2

Please sign in to comment.