Issue with "No Web Processing" and "Method Not Allowed" Errors After Deploying Django App to Heroku

I’m deploying my Django app to Heroku, but after following all the necessary deployment steps, I’m facing persistent issues. These errors appear after deployment, and I’ve tried various troubleshooting methods but haven’t resolved the problem.
Here’s a summary of the situation and the steps I’ve taken:

Error Overview:

  • Logs show:
    • Method=GET path=“/” and path=“/favicon.ico”
    • status=503 service error
    • no web processes running
    • HTTP Status: Method Not Allowed

Steps Taken to Resolve the Issue:

  1. Created a Procfile in the root directory of my project containing:

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

    • I verified that the spelling of Procfile is correct (with a capital ‘P’).
    • My requirements.txt file includes gunicorn, Django, and all other dependencies.
  2. Pushed to Heroku:

    • I committed all changes and pushed to the Heroku remote using:

    • bash

      git push heroku main

  3. Run Migrations:

    • Successfully ran database migrations on Heroku using:

      bash

      heroku run python manage.py migrate

  4. Scaled Dynos:

    • Attempted to scale the web dynos using:

      bash

      heroku ps:scale web=1

    • Result: Received an error stating no web processes running.

  5. Django Settings Configuration:

    • Added the Heroku app URL to ALLOWED_HOSTS:
      python
      ALLOWED_HOSTS = [rentaltz.herokuapp.com]

    • Configured static files and Whitenoise correctly as shown:
      python
      MIDDLEWARE = [
      ‘django.middleware.security.SecurityMiddleware’,
      ‘whitenoise.middleware.WhiteNoiseMiddleware’,
      ‘django.contrib.sessions.middleware.SessionMiddleware’,
      ‘django.middleware.common.CommonMiddleware’,
      ‘django.middleware.csrf.CsrfViewMiddleware’,
      ‘django.contrib.auth.middleware.AuthenticationMiddleware’,
      ‘django.contrib.messages.middleware.MessageMiddleware’,
      ‘django.middleware.clickjacking.XFrameOptionsMiddleware’,
      ]

  6. Checked Logs:

    • The Heroku logs display the following message:

      bash
      at=error code=H14 desc=“no web dynos running”

    • It seems that the web dynos are not properly activated.

  • I’ve followed best practices for setting up the project for Heroku (e.g., using gunicorn, adding static file handling with Whitenoise, and ensuring the correct environment variables).
  • I’ve tried different branches and even attempted a full redeployment but continue facing the same issue.
  • Locally, the app works perfectly fine.

Could someone kindly help me understand why I’m getting these errors, specifically the “no web processing” issue? Is there something wrong with my configuration, or am I missing a critical step? Any guidance or feedback on my approach would be highly appreciated.

My application logs

2024-10-03T13:13:01.420650+00:00 heroku[router]: at=error code=H14 desc=“No web processes running” method=GET path=“/” request_id=07e12b5e-b27d-45d8-9ec0-166177a8fff2 fwd=“196.249.93.176” dyno= connect= service= status=503 bytes= protocol=https
2024-10-03T13:13:02.346626+00:00 heroku[router]: at=error code=H14 desc=“No web processes running” method=GET path=“/favicon.ico” request_id=0d50e691-0e01-496a-b75b-0d0f0e427296 fwd=“196.249.93.176” dyno= connect= service= status=503 bytes= protocol=https
2024-10-04T08:54:53.088315+00:00 heroku[router]: at=error code=H14 desc=“No web processes running” method=GET path=“/” request_id=f917a615-f461-4321-a5ac-c2aedd1569b6 fwd=“196.249.99.156” dyno= connect= service= status=503 bytes= protocol=https
2024-10-04T08:54:54.663342+00:00 heroku[router]: at=error code=H14 desc=“No web processes running” method=GET path=“/favicon.ico” request_id=e0604ed2-3cca-4ce8-8da5-f071254f8b71 fwd=“196.249.99.156” dyno= connect= service= status=503 bytes= protocol=https
2024-10-04T08:54:56.365734+00:00 heroku[router]: at=error code=H14 desc=“No web processes running” method=GET path=“/” request_id=6170a693-93c0-4f03-8736-3268bc198791 fwd=“204.85.30.68” dyno= connect= service= status=503 bytes= protocol=https
2024-10-04T08:55:22.709282+00:00 heroku[router]: at=error code=H14 desc=“No web processes running” method=GET path=“/” request_id=ada403d1-077c-443f-b13c-cadf786e2e38 fwd=“196.249.99.156” dyno= connect= service= status=503 bytes= protocol=https
2024-10-04T08:55:23.245404+00:00 heroku[router]: at=error code=H14 desc=“No web processes running” method=GET path=“/favicon.ico” request_id=439656a1-d9a1-44fc-a7f2-ed1ee8bb0a20 fwd=“196.249.99.156” dyno= connect= service= status=503 bytes= protocol=https
2024-10-04T10:21:36.520687+00:00 app[api]: Stack changed from heroku-22 to heroku-24
2024-10-04T10:22:02.792107+00:00 heroku[router]: at=error code=H14 desc=“No web processes running” method=GET path=“/” request_id=82b27542-6b72-42ca-87fa-ffcf9643b182 fwd=“196.249.99.156” dyno= connect= service= status=503 bytes= protocol=https
2024-10-04T10:22:03.393064+00:00 heroku[router]: at=error code=H14 desc=“No web processes running” method=GET path=“/favicon.ico” request_id=8fdce0a6-e861-428b-8d16-a3a9f6a1d65c fwd=“196.249.99.156” dyno= connect= service= status=503 bytes= protocol=https

This looks like an issue with how you are deploying Heroku as opposed to Django.

Based on your Heroku error logs, I see the following: H14 desc=“No web processes running”, which, from a quick Google, brings me to the following page on Heroku’s guide with a command to run to solve it: Heroku Error Codes | Heroku Dev Center

This is most likely the result of scaling your web dynos down to 0 dynos. To fix it, scale your web dynos to 1 or more dynos:

$ heroku ps:scale web=1
1 Like

Heroku ps: scale web=1

It still gives errors

Error: Couldn’t find that process type ( web)
Error ID: not_found

This question would best work on Heroku’s forum since it’s Heroku specific, but I’ll another stab at trying to solve it based on my brief experience with Heroku in the past.

  1. Can I verify that your Django project is named Django_project? You should be able to find a file wsgi.py, i.e. Django_project/wsgi.py

  2. Your Procfile does not contain any file extensions, i.e. it’s it not named Procfile.txt or something else

  3. Your Procfile is committed and pushed successfully, i.e. git push heroku main

If all three are true, you may need to try and rebuild your app, following instructions on this page: https://help.heroku.com/W23OAFGK/why-am-i-seeing-couldn-t-find-that-process-type-when-trying-to-scale-dynos

To fix
Remove the existing buildpacks with heroku buildpacks:clear and add them again in the right order using the heroku buildpacks:add with the --index option, making sure that the language buildpack is the last in the list.
You will need to add an empty commit and redeploy for the changes to take effect:

git commit --allow-empty -m "Adjust buildpacks on Heroku"
git push heroku master
1 Like