0

I am trying to deploy my very first Django applicatin on heroku. Gunicorn gives me this error: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>

In this answer https://stackoverflow.com/a/55623889 command gunicorn app:application --preload -b 0.0.0.0:5000 is said to give detailed error message, but as its comments state it is not clear what words to replace with what. For instance somewhere I saw something similar called with <name of my app>.wsgi. To make matter worse name of my Django app in local is different from the one on Heroku.

Also it is not clear to me should this be called strait from terminal (within virtual env) or should I be using some sort of gunicorn CLI.

So what is the actual propper way to figure out what is failing gunicorn?

Heikki
  • 341
  • 2
  • 18

1 Answers1

1

I've faced similar issues in the past. I hope this might help:

  1. Make sure gunicorn is installed in your activated virtual environment project by running pip freeze in the terminal to verify it's installation. If it is not listed, in the activated virtual environment, run pip install gunicorn or else if you are using pipenv, run pipenv install gunicorn. Don't forget to update the requirements.txt file by running pip freeze > requirements.txt

  2. In the Procfile which is within the project_directory type the syntax:

web: gunicorn your_django_project_name.wsgi --log-file -

N.B: There should be a space between;

  1. The --log-file and the - next to it.
  2. web: and the gunicorn part of the code.

Finally add, commit and push the changes to the heroku server.

eManuel
  • 23
  • 1
  • 7
  • Thanks for answer! This fixes error I mentioned. At some point I had removed gunicorn from ``requirements.txt`` trying to fix some other problem, even though I manualy entered gunicorn version specifically to it. Unfortunately another error arose: ``code=h14``. This seems to be problem with dynos as said here: https://devcenter.heroku.com/articles/error-codes#h14-no-web-dynos-running . However using ``heroku ps:scale web=1`` gave me this error in terminal: ``Scaling dynos... ! ▸ Couldn't find that process type (web).``. This in turn led something about Procfile being wrong. Any idea? – Heikki May 29 '22 at 00:20
  • Most welcome! I have encountered such errors before. I tried to change to `heroku ps:scale web=0` and then changed back to `heroku ps:scale web=1` if the `web=0` did not work. In the cases where the error persisted, I then tried to do a clean deployment procedure. You can also try the solutions listed in [here](https://stackoverflow.com/q/48512013/9448032) – eManuel May 29 '22 at 19:57
  • Also make sure the `Procfile`, `requirements.txt` and the `runtime.txt` are contained in the root of the project where some other files such as `manage.py` are located. They should all be together. – eManuel May 29 '22 at 20:35