My Dockerfile exposes two ports, 8080 and 49322. One is for a web server and the other for a websocket server.
How do I setup the services part of fly.toml so that there are two ports that accept traffic from the internet? 8080 is already handled, but how do I setup another one for 49322?
I tried adding a copy of the [[services]] used for 8080 and just changed the 8080 and 80 to 49322 instead. What happened then was that the app successfully deployed but visiting it doesn’t even render a page, it couldn’t be reached, the browser just gets an ERR_CONNECTION_RESET.
It is possible to expose multiple ports. Yes, multiple [[services]] is indeed the way to do it. Strange that didn’t work for you … hmm. Check this Fly app’s fly.toml which exposes multiple ports to see how they do it and compare it to yours to see what you need to do:
Hold on… I just visited my deployed app and it’s visitable, no more browser error.
So maybe I was simply just experiencing some downtime after a deploy before it actually became reachable? It’s been a couple of hours since I tried deploying it so not sure how long it took for it to become reachable.
All apps are different and some take longer to start up than others, depending on what they are doing. External stuff etc. You can handle that to some extent using health checks, along with the grace_period value. I’d suggest adding both tcp and http healthchecks to your fly.toml (if not already) with a grace_period. Then Fly will only say the deployment was successful and start routing requests to it once they pass. And if it can reach your app and get a response, well everyone else should be able to (like your browser). Check this part and scroll down: