I’ve looked at all the previous articles related to the error stating that my app isn’t listening to the right port.
[PC01] instance refused connection. is your app listening on 0.0.0.0:8080? make sure it is not only listening on 127.0.0.1 (hint: look at your startup logs, servers often print the address they are listening on)
The steps I’ve taken to correct this are
Set the IP and Port on my Spring Boot app to 0.0.0.0 and 8080
Set the exposed port on my Docker file to 8080 with “EXPOSE 8080”
Set the port on the fly.toml file using “internal_port = 8080”
None of these have seemed to correct this issue and when I took a look at the configuration from the fly.io dashboard, I see that my port is actually not 8080, but seems to have a typo involved “internal_port = 8_080”
Since this is not something editable, I have tried to replace and reload it, but every time the result is the same “8_080”. I am unsure if this is typical behavior or if this is in fact the issue that I am facing.
If anyone can assist, I would be greatly appreciative.
Did you forget the 0 or did codegen generate the wrong port?
TOML lets you use the underscore for human readability, ie 8_080 is the same as 8080.
What does your full Dockerfile and fly.toml look like?
Strange… I just double checked all my apps and it had the correct port, eg 3_000. Try deleting your app and relaunching it? Maybe you had a typo when you first launched.
Just to confirm, having it say 8_080 is a correct display of the port? If so, then it seems like it’s configured correctly and I’m still unsure of why I’m getting constant errors about the wrong port and why the app is only loading occasionally.
I also noticed that when I re-deploy the app, about half the time I will see this error appear. It’s not consistent as I’ve run the deploy again after it appeared and immediately it was gone the next time.
Updating existing machines in ‘app’ with rolling strategy
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:
0.0.0.0:8080d lease for 6###########
I have replaced values with # in that just in case that is sensitive info
I am not sure why the d is there, it doesn’t appear in the configuration panel nor does it appear in the error that shows in the logs. It’s not being entered by anything on my end, that shows up in terminal while deploying.
If the app sometimes does load, I doubt the port or address is the issue. I won’t say it’s impossible, but you can get this warning simply because your app is not yet listening at the expected address when this check happens, even though a few seconds later, once the app is fully booted, Fly Proxy is happily delivering traffic to it. (I happen to have rambled a bit about this and Machine IP addresses recently after I hit this false alarm while deploying my new blog site.)
If your app is only sometimes working after deployment, I’d start with the app logs to see if there are clues in there. Sometimes I’ll also fly ssh console in and use netstat to see what’s actually listening on which ports inside my Machine.
The following looks like a terminal display glitch with the end of a line like “Acquired lease for <machine-id>” (or something) mashed up with the info message about the address, which would explain the extra d:
Thank you for that insight about it needing the app to fully boot first. I will definitely be testing to see if there are any instances of that appearing post-boot. I was also concerned because of the error being displayed when deploying so I’ll keep an eye out for that but if it still works after booting then it may just be incorrectly flagged during deployment.