Deployment succeed but address not be reachable by fly-proxy

So I am testing to deploy a Nextjs app in docker but on the second one I get this classic error:

WARNING The app is not listening on the expected address and will not be reachable by fly-proxy.
You can fix this by configuring your app to listen on the following addresses:
Found these processes inside the machine with open listening sockets:
  PROCESS                  | ADDRESSES                             
  next-router-wo           | [::1]:3000, [::]:33043                
  /.fly/hallpass           | [fdaa:1:c0e0:a7b:169:9f19:3d07:2]:22  
  next-render-worker-app   | [::1]:44261                           
  next-render-worker-pages | [::1]:39227

The fly.toml setting is the same

  internal_port = 3000
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 0
  processes = ["app"]

and I expose PORT 3000 in the Dockerfile, but somehow on the 1st app I successfully listen to localhost:3000 like in the log below

2023-08-26T21:36:46.165 proxy[1857507c431308] cdg [info] Starting machine
2023-08-26T21:36:46.336 app[1857507c431308] cdg [info] [ 0.035956] PCI: Fatal: No config space access function found
2023-08-26T21:36:46.543 app[1857507c431308] cdg [info] INFO Starting init (commit: b437b5b)...
2023-08-26T21:36:46.559 app[1857507c431308] cdg [info] INFO Preparing to run: ` node server.js` as nextjs
2023-08-26T21:36:46.566 app[1857507c431308] cdg [info] INFO [fly api proxy] listening at /.fly/api
2023-08-26T21:36:46.569 app[1857507c431308] cdg [info] 2023/08/26 21:36:46 listening on [fdaa:1:c0e0:a7b:16a:c3d2:dd13:2]:22 (DNS: [fdaa::3]:53)
2023-08-26T21:36:46.606 proxy[1857507c431308] cdg [info] machine started in 442.213403ms
2023-08-26T21:36:47.158 app[1857507c431308] cdg [info] Listening on port 3000 url: http://localhost:3000

however the second one failed as expected with the error:

2023-08-26T21:34:55.047 app[e82d525c727158] cdg [info] INFO Starting init (commit: b437b5b)...
2023-08-26T21:34:55.060 app[e82d525c727158] cdg [info] INFO Preparing to run: ` node server.js` as nextjs
2023-08-26T21:34:55.067 app[e82d525c727158] cdg [info] INFO [fly api proxy] listening at /.fly/api
2023-08-26T21:34:55.069 app[e82d525c727158] cdg [info] 2023/08/26 21:34:55 listening on [fdaa:1:c0e0:a7b:127:f8b5:c23a:2]:22 (DNS: [fdaa::3]:53)
2023-08-26T21:34:55.563 app[e82d525c727158] cdg [info] - ready started server on [::1]:3000, url: http://[::1]:3000
2023-08-26T21:34:55.881 app[e82d525c727158] cdg [info] - info Loaded env from /app/.env
2023-08-26T21:34:56.096 app[e82d525c727158] cdg [info] - info Loaded env from /app/.env
2023-08-26T21:35:22.070 proxy[d8d9e16c2d5118] cdg [error] instance refused connection. is your app listening on make sure it is not only listening on (hint: look at your startup logs, servers often print the address they are listening on)

i am still new using the flyctl so I wonder how can i fix this issue ? could it be memory issue ? But I don’t see any OOM error message. Or there is something I am missing to set ?

What that means is that you only will accept connections from localhost (i.e., the same machine as your app is running on), and not from the internet. This needs to be (or [::]) to accept connections from the internet.

Would it be possible to change server.js to listen to one of these two addresses instead of localhost?

Oh Ok I see… i was wondering how to set this since I am not using a custom server.js file in Nextjs app, looks like the issue is coming from Nextjs, since in the next.config file is set to output: standalone, it listen only to localhost as you mention, so in the Dockerfile I try to change the hostname like this:


and now it finally work… Thank you!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.