H14 Error on Heorku |
Today morning I did a new push to www.bikenomads.co.in with images from the fantastic 2013 calendar.
And the website died :(
One minute it was working fine, and the next it died ! Showing a problem with the app, and if you are the administrator to check the logs.
It took me 2 hrs to fix this, as Heroku site is not clear on what to do in case of errors ( see here for list of errors in Heroku) . So, here's a short guide to fix it ( this guide is for a Django project but I think it should work out similarly for other platforms )
First , if the app is not loading , check the logs in heroku. So, I logged into the web console and could not find the error log at all ! Apparently you need to use the command line for the logs as :
$ heroku logs
and it showed something like this to me :
2013-02-16T08:35:49+00:00 heroku[web.1]: Process exited with status 143
2013-02-16T08:35:51+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path=/ host=www.bikenomads.co.in fwd="122.161.143.22" dyno= queue= wait= connect= service= status=503 bytes=
The what ?! Web process exited ?? Then how will the site run ? I checked the web console and it did not show anything under "Dynos" ( I am also not sure if it existed 2 months back?)
Check with heroku ps if there is any process running:
$ heroku ps
That did not return anything.
So, a bit of search over the net and stackexchange pointed to something called the Procfile - which I had never used before. Apparently, heroku picks up the info on what to run automatically, but sometimes it jinxes. It is safer to put the information into a Procfile . This problem seems to keep recurring for over a year, but Heroku guys have not fixed it or fixed their tutorials, and that is where it all starts going downhill.
Now follow the steps below to fix it for your installation :
1. Create a file called Procfile ( it is case sensitive - so capitalize P !) in the root directory of your application ( where you have the venv folder ) . On windows you will have to make sure that windows does not add a .txt extension . I use linux so it was just 'touch Procfile'.
2. Edit the file and put in the following details for Django ( other apps you will need to figure out depending on what is needed to run it ) :
4. Remember the heroku ps did not give any results earlier ? So, now you need to attach the process. Do this with the following command to add a web dyno :
2. Edit the file and put in the following details for Django ( other apps you will need to figure out depending on what is needed to run it ) :
web: python website/manage.py runserver 0.0.0.0:$PORT3. git add the file and do a git push heroku master to push this file to the server. We are not done yet even though the push says everything is fine.
Note the spacing and the IP you need to give. If you miss out the last part, it will run on localhost which you will not be able to connect to from your machine.
4. Remember the heroku ps did not give any results earlier ? So, now you need to attach the process. Do this with the following command to add a web dyno :
$ heroku ps:scale web=1
Scaling web processes... done, now running 1
Check your website now and it should be working !
And check out my site : http://www.bikenomads.co.in