Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

1K
Visualizações
Heroku deployment of Fastapi (Python) running on uvicorn: Web process failed to bind to $PORT

We have a python 3.9 fastapi server that we are trying to get running on uvicorn on heroku. It comes up fine when we start it on a heroku run bash instance but when it launches normally on the dyno manifold the port doesn't bind.

heroku/web.1 Starting process with command `uvicorn app.main:app --workers 4 --port 42374`
app/web.1 INFO:     Uvicorn running on http://127.0.0.1:42374 (Press CTRL+C to quit)
app/web.1 INFO:     Started parent process [4]
app/web.1 INFO:     Started server process [13]
app/web.1 INFO:     Waiting for application startup.
app/web.1 INFO:     Started server process [10]
app/web.1 INFO:     Waiting for application startup.
app/web.1 INFO:     Started server process [12]
app/web.1 INFO:     Waiting for application startup.
app/web.1 INFO:     Started server process [11]
app/web.1 INFO:     Waiting for application startup.
app/web.1 INFO:     Application startup complete.
app/web.1 INFO:     Application startup complete.
app/web.1 INFO:     Application startup complete.
app/web.1 INFO:     Application startup complete.
heroku/web.1 Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
heroku/web.1 Stopping process with SIGKILL
heroku/web.1 Process exited with status 137
heroku/web.1 State changed from starting to crashed

If I run it locally using Heroku CLI:

root@d2258955b223:/workspaces/app-service-cross-sell# heroku run bash
Running bash on ⬢ aci-sell-service... up, run.4472 (Hobby)
~ $ uvicorn app.main:app --workers 4 --port $PORT
INFO:     Uvicorn running on http://127.0.0.1:26281 (Press CTRL+C to quit)
INFO:     Started parent process [141]
INFO:     Started server process [144]
INFO:     Waiting for application startup.
INFO:     Started server process [145]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Application startup complete.
INFO:     Started server process [143]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Started server process [146]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
^Z
[1]+  Stopped                 uvicorn app.main:app --workers 4 --port $PORT
~ $ bg
[1]+ uvicorn app.main:app --workers 4 --port $PORT &
~ $ curl http://localhost:26281
INFO:     127.0.0.1:55674 - "GET / HTTP/1.1" 200 OK

App loads from:

if __name__ == "__main__":
    uvicorn.run(
        "main:app",
        host="0.0.0.0",
        port=config.PORT,
        reload=not config.DEBUG,
        debug=config.DEBUG,
        log_level=VLabLogger.get_log_level_based_on_env().lower(),
    )
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I would suggest creating a Procfile having:

web: uvicorn main:app --host=0.0.0.0 --port=${PORT}

and let heroku handle the PORT.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda