I’ve been trying to set up a production environment for my flask app using Replit Deployments.
In my current attempt, I use gunicorn to run my server.
But when I call my deployed API I just get a
Bad Gateway response.
Does anyone have any guidance to offer here on what the best way would be to fix this and run production Flask on Replit Deployments?
The server works fine in the normal Replit environment, ran in development mode with
Also tried with “gunicorn main:app” in case trying to specify the number of workers was the problem. That just failed to deploy completely.
Hey, I can look into this for you if you share a link to the repl. Have you read through the troubleshooting guide? In particular, is there anything in the logs tab that indicates an error has occurred?
Forked it here for you to see. Thanks for the reply
I don’t see an error in the logs
Sorry for the delayed response – the issue here was that you were deploying it as a “Background Worker” rather than a “Web Server”. It looks like you might have figured this out already, is your deployment working now?
Sadly it just fails at the “Promote” stage when I try to deploy it as a “web server” using “gunicorn main:app”
Another possibility is that it is failing to work because gunicorn might be causing it to only listen on 127.0.0.1, whereas it needs to be listening on 0.0.0.0 in order to work. A good test for this is to run the same command in the Replit Workspace, and if it works there it should work in the deployment.
when i run the gunicorn command in the Replit shell it works fine and I can use the API. Worked when I used 127.0.0.1 as my host and 0.0.0.0
But sadly using the same command for Deployment still gives me: “The deployment failed to initialize due to a configuration or code error”
did you manage to resolve this?
Having similar issues here, failing at the Promote stage when using gunicorn as a run command. @lincoln-replit this occurs even when using
@datadesigns I’ll message you, your issue looks potentially unrelated to gunicorn.