pardon the question as I am new to backend deployment
I have the a very simple program
from fastapi import FastAPI
from fastapi.encoders import jsonable_encoder
app = FastAPI()
@app.get('/')
async def root():
return jsonable_encoder({'message': 'hello world'})
I deploy on Heroku with the Procfile as so
web: uvicorn main:app --workers 4
I’m getting the following error
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
I have read some other questions such as
/questions/14322989/first-heroku-deploy-failed-error-code-h10
They ask to make sure that I’m listening on the right port, the one that Heroku provides. However I’m not specifying any port in the code so I’m not sure how I can fix this?
Found the answer, I just changed the Procfile to this
web: uvicorn main:app –host=0.0.0.0 –port=$PORT –workers 4