Address already in use

I have a website having an issue deploying as below:

2023-04-07T15:27:47.154 app[99020708] iad [info] * Serving Flask app 'main'

2023-04-07T15:27:47.154 app[99020708] iad [info] * Debug mode: on

2023-04-07T15:27:47.158 app[99020708] iad [info] Address already in use

2023-04-07T15:27:47.158 app[99020708] iad [info] Port 8080 is in use by another program. Either identify and stop that program, or start the server with a different port.

2023-04-07T15:27:47.158 app[99020708] iad [info] [2023-04-07 15:27:47 +0000] [749] [INFO] Worker exiting (pid: 749)

2023-04-07T15:27:47.265 app[99020708] iad [info] [2023-04-07 15:27:47 +0000] [750] [INFO] Booting worker with pid: 750

2023-04-07T15:27:47.669 app[99020708] iad [info] * Serving Flask app 'main'

2023-04-07T15:27:47.669 app[99020708] iad [info] * Debug mode: on

2023-04-07T15:27:47.673 app[99020708] iad [info] Address already in use

It’s always seeing this “address already in use” problem. I’ve tried SSHing into the machine and killing the gunicorn processes, but they just restart and show the same issue. I’ve tried changing ports from 8080 many times, but still nothing. I’ve tried a lot of other things as mentioned – the machine seems started and healthy.

Is there anything in particular I should be looking for in my app that might be causing this? Procfile looks like this:

# Modify this Procfile to fit your needs
web: gunicorn main:app

And fly.toml like this:


app = "verge-app-deploy"
kill_signal = "SIGINT"
kill_timeout = 5
primary_region = "iad"
processes = []

[build]
  builder = "paketobuildpacks/builder:full"

[env]
  PORT = "8080"

[experimental]
  auto_rollback = true

[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []
  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

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

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

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

Update: as expected, as soon as I posted this I got the solution. This was a student project, and the students were not properly running their apps. For future people running into this issue, the group needed to have the name == “main” for running their app, and this had been missing.

if __name__ == "__main__":
    app.secret_key = os.urandom(12)
    app.run()
1 Like

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