Heroku Application error
Heroku Application error

How to solve application error while deploying django project on Heroku

May 31

I know how hard it is to build a application and complete the final testing when all is ready we will be so excited to launch. Oh there is an error while deploying 😭😭😭. I know how it feels because I have met all those errors while deploying this website application on Heroku. This app which you are currently in (platiplus.com) is hosted in Heroku. Let's solve the error together. Be happy I am there with you to help you solve the errors. So the world can see the great application you've created. 

1. Find the root cause for the error. 

First find out whether the error is caused by the application itself or the error is due to Heroku. It may be caused due to improperly configured WSGI (web server gateway interface) or Procfile may not be identified.

Note : if you don't know how to host your application in Heroku go to the post I've put earlier and come back. In that post I've  explained how to host and use Heroku  postgressql database.

How to find the root cause ?

It's so simple in the CLI run any django command for example run

Heroku run python manage.py create superuser 

If it produces an error then the error is due to your application read the error and copy and search in google. There will be solution especially in stack overflow if you don't find the solution contact me through Instagram or e-mail or put it in the comment sections. I'd love to help 🤞👍💖. 

If it doesn't produce error then its more likely to be caused by Heroku go to Heroku dashboard and to your app and check your logs if it doesn't show you errors then go to command line either Heroku CLI or  Git bash or whatever you use then type this command

heroku logs --tail --app <your_app_name>

You Could see errors and error code like below

Error I faced
Error I faced

Here you can find all error codes. I particularly faced error with error code H14. This error is probably caused because git may not tracked the changes to your Procfile.  So let's see the fixe for this error. 

Fix 1:

  1. Delete your Procfile
  2. git add .
  3. git commit ( commit the changes )
  4. Add the Procfile again ( web: gunicorn <Your app name>.wsgi )
  5. git add .
  6. git commit ( Commit your change again )
  7. git push
  8. git push Heroku <Your git branch>

If this solution doesn't work for you then try pushing your branch to heroku before adding the Procfile again

Fix 2:

In the heroku docs they tell that the error may be caused due to dynos. ie.. No dynos running. To fix this you need to scale your dynos from 0 to 1. To scale run the following command.

heroku ps:scale web=1

This will scale your dynos from 0 to 1. The Heroku Platform uses the container model to run and scale all Heroku apps. The containers used at Heroku are called “dynos.”  More about dynos here

Fix 3:

Try restarting your dynos

heroku restart

If you are still facing problem put it in the comments  section or feel free to contact me through Instagram or e-mail or put it in the comment sections. I'd love to help 🤞👍💖.  or you can contact heroku support or put your errors in stackoverflow

More from the author

Heroku Application error

How to solve application error while deploying django project on Heroku

Comments (0)

Add a Comment