Unable to connect to my app after a succesful deploy

My python app runs correctly on localhost. I can access it on port 8080. I’ve exposed this service on port 80 and 443 with http and tls, http handlers. I’m still unable to connect to my app over its fly.dev domain.


app = "fruit-loops-bot"

[build]
  builder = "paketobuildpacks/builder:base"
  buildpacks = ["gcr.io/paketo-buildpacks/python"]

[[services]]
  internal_port = 8080
  protocol = "tcp"

  [[services.ports]]
    handlers = ["http"]
    port = "80"
    force_https = true

  [[services.ports]]
    handlers = ["tls", "http"]
    port = "443"

First place to check is the logs. With the CLI try fly logs from the folder your app is in. That shows the most recent entries. Can show any issues, errors etc which might explain why it doesn’t respond.

Another good idea is to add healthchecks as it might seem like you app is working, but it actually isn’t. You can stop the deploy proceeding if the app is not responding to requests. I’d suggest adding both a tcp and http healthcheck to the fly.toml file. That way, if the app is not actually responding, you will see that as part of fly deploy and debug there, rather than have it deploy and only find that out then:

I’ve ruled out all of the usual suspects already. Logs are clean. I’m even able to connect to the app over a wireguard tunnel to my fly org. When I connect over the app’s fly.dev domain, I get “Error connection closed” in the browser.

The healthchecks are passing too. The app is supposedly running, but I get nothing.

Does my app have to listen on any particular host or is 127.0.0.1 fine?

Hmm :thinking: I wonder if it that’s it. Maybe try either 0.0.0.0 (IPv4) or :: (IPv6) e.g this Fastify app line 22 listens on :: and that works:

If not, then I’d check the app is listening on port 8080, as your fly.toml specifies it to be.

Ok i see the problem. The health check is failing. I’m not sure why though. I can connect to my app over 8080 via wireguard. It’s also listening on all interfaces now.

Doesn’t seem to be anything on my end. For what it’s worth, another app with a very similar setup on a different fly org is working perfectly.

OK figured it out with a clear head. It was the interfaces thing. Fly proxy is unable to talk to the app if it only listens on localhost.

How do you know if your app only listens to localhost ?

Hi, I have the same issue in my node js application. How can I know if my app only listens to localhost?

Some more information here: Listening Ports · Fly Docs

Is your app calling listen directly, or are you using a higher order framework which starts the server for you?

I’m using express and socket.io

const app = express();

const server = require('http').createServer(app);
module.exports.io = require('socket.io')(server);

server.listen(PORT, hostname, () => {
  logger.info(`System launch on http://${hostname}:${PORT}`);
});

I’m using PORT=3000 and hostname = ‘0.0.0.0’