[Answered ]-/bin/bash: line 1: gunicorn: command not found

1👍

I’m 6 months late but this finally might be a question I can actually answer. I’m fairly new to all this and working with flask, not django, so take this all with a grain of salt

That said, I was getting the same error message trying to get a flask application deployed on Railway. Here’s what solved it for me:

1.) In your IDE/virtual environment, from the terminal (if you’ve not done this already):

pip install gunicorn 

2.) From the terminal,

pip freeze > requirements.txt

to generate/update the requirements.txt file. Make sure gunicorn is included in it

3.) Create a file called "Procfile" in the working directory – the capitalization is important. Also, it must NOT have a file extension

4.) Within the "Procfile", include this one line of text:

web: gunicorn main:app

where "main" is the name of your main python file. So if your main file was named "asdfjkl.py", you’d put this in the Procfile:

web: gunicorn asdfjkl:app

Make sure you have the spaces set up like above

5.) Start a github repo for the project/commit the latest files to it (including requirements.txt and the Procfile)

6.) Go to railway, open a new flask app project, and link to that github repo. Should deploy successfully after that (or at least give a new error message)

I’ve done this now with 2 different flask apps and that seems to have solved the problem for me. Or at least gotten me to a different log error unrelated to gunicorn. Hope this helps!

Leave a comment