"Internal Server Error" on Heroku in Django/Mezzanine app - django

I'm deploying my Mezzanine app on heroku, and I think I've finally set most things up.
Now though, every page of my app gives an Internal Server Error, and no logs mention anything error-like at all. Same error on local as well.
The logs from the command 'heroku logs' look like this:
2014-09-03T07:07:52.555930+00:00 heroku[web.1]: Starting process with command `g
unicorn wsgi -b 0.0.0.0:30978 -w 1`
2014-09-03T07:07:53.900072+00:00 heroku[web.1]: State changed from starting to u
p
2014-09-03T07:08:27.706884+00:00 heroku[router]: at=info method=GET path="/" hos
t=sheplusplus.herokuapp.com request_id=70b72520-1094-4ed7-83d7-ff44277c603b fwd=
"98.234.178.149" dyno=web.1 connect=2ms service=5ms status=500 bytes=713
2014-09-03T07:08:29.832027+00:00 heroku[router]: at=info method=GET path="/" hos
t=sheplusplus.herokuapp.com request_id=5a32f20e-5244-4f15-9e4b-dadd6b0fcfbb fwd=
"98.234.178.149" dyno=web.1 connect=2ms service=3ms status=500 bytes=713
2014-09-03T07:08:31.720436+00:00 heroku[router]: at=info method=GET path="/" hos
t=sheplusplus.herokuapp.com request_id=9ed6536a-3bb3-4dd9-904c-b2b3f1db2827 fwd=
"98.234.178.149" dyno=web.1 connect=2ms service=3ms status=500 bytes=713
and the logs from Papertrail look like this:
Sep 03 00:07:48 sheplusplus heroku/web.1: State changed from up to starting
Sep 03 00:07:51 sheplusplus heroku/web.1: Stopping all processes with SIGTERM
Sep 03 00:07:52 sheplusplus heroku/web.1: Process exited with status 0
Sep 03 00:07:52 sheplusplus heroku/web.1: Starting process with command `gunicorn wsgi -b 0.0.0.0:30978 -w 1`
Sep 03 00:07:54 sheplusplus heroku/web.1: State changed from starting to up
Sep 03 00:08:28 sheplusplus heroku/router: at=info method=GET path="/" host=sheplusplus.herokuapp.com request_id=70b72520-1094-4ed7-83d7-ff44277c603b fwd="98.234.178.149" dyno=web.1 connect=2ms service=5ms status=500 bytes=713
Sep 03 00:08:30 sheplusplus heroku/router: at=info method=GET path="/" host=sheplusplus.herokuapp.com request_id=5a32f20e-5244-4f15-9e4b-dadd6b0fcfbb fwd="98.234.178.149" dyno=web.1 connect=2ms service=3ms status=500 bytes=713
Sep 03 00:08:31 sheplusplus heroku/router: at=info method=GET path="/" host=sheplusplus.herokuapp.com request_id=9ed6536a-3bb3-4dd9-904c-b2b3f1db2827 fwd="98.234.178.149" dyno=web.1 connect=2ms service=3ms status=500 bytes=713
My procfile looks like so:
web: gunicorn wsgi -b 0.0.0.0:$PORT -w 1
I have no idea how to begin fixing this because I see absolutely nothing wrong.

locally do:
python manage.py runserver
And watch the output when you load a page. It should expose the error in a clearer message.

Related

heroku H10 issue

I am geting the Error:
at=error code=H10 desc="App crashed" method=GET path="/" host=quiz-iu.herokuapp.com request_id=9ee6412c-b248-4eeb-8eba-066f07b38a4f
fwd="93.201.118.59" dyno= connect= service= status=503 bytes= protocol=https
2022-12-19T17:47:36.743985+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=quiz-iu.herokuapp.com request_id=071363bb-8ce2-4eed-bdc5-93cd3b39581f fwd="93.201.118.59" dyno= connect= service= status=503 bytes= protocol=https
And if I set into the consul : heroku run rails console,
I get: bash: line 1: rails: command not found
Can someone please help me fix this issue?
A few things to confirm:
Make sure that git is initialized in the same directory where the manage.py file is located.
Make sure that the Procfile is written with the capital P and the rest in small letters, as written in this sentence.
Make sure that the Procfile, requirements.txt, and runtime.txt (if you have one) are in the same directory as the manage.py file.
Copy-paste the following line as it is in your Procfile and replace djangoheroku with the name of your Django project.
web: gunicorn djangoheroku.wsgi --log-file -
Note: Don't forget to replace djangoheroku with the name of your Django project.

Heroku Application Erros Django

I don't understand why this application error. I followed djangogirls-extension deploy tutorial.
here is the output of >heroku logs --tail --app srms-demo command
2019-02-09T02:31:06.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/9822ee2e-0b33-4163-9dd1-5d9897a5b7c7/activity/builds/e01929d2-7a31-45fe-97c3-90eab053a667
2019-02-09T02:47:00.587192+00:00 heroku[run.9364]: State changed from up to complete
2019-02-09T02:50:39.686144+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=srms-demo.herokuapp.com request_id=5859852f-3ae2-47c8-9f6e-3ba05f1c5bbb fwd="43.245.123.100" dyno= connect= service= status=503 bytes= protocol=https
2019-02-09T03:10:39.561398+00:00 heroku[run.2791]: Process exited with status 0
2019-02-09T03:11:20.141798+00:00 heroku[run.6801]: State changed from up to complete
2019-02-09T03:15:30.610720+00:00 heroku[web.1]: State changed from crashed to starting
then is visited error link and found this
-----> Python app detected
! Requested runtime (python-3.7) is not available for this stack (heroku-18).
! Aborting. More info: https://devcenter.heroku.com/articles/python-support
! Push rejected, failed to compile Python app.
! Push failed
Update
After changing runtime.txt to python-3.7.1 pushed it on Heroku master
here is the output of heroku logs --tail --app srms-demo command
2019-02-09T02:31:06.000000+00:00 app[api]: Build failed -- check your build output: https://dashboard.heroku.com/apps/9822ee2e-0b33-4163-9dd1-5d9897a5b7c7/activity/builds/e01929d2-7a31-45fe-97c3-90eab053a667
2019-02-09T02:47:00.587192+00:00 heroku[run.9364]: State changed from up to complete
2019-02-09T02:50:39.686144+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=srms-demo.herokuapp.com request_id=5859852f-3ae2-47c8-9f6e-3ba05f1c5bbb fwd="43.245.123.100" dyno= connect= service= status=503 bytes= protocol=https
2019-02-09T03:10:39.561398+00:00 heroku[run.2791]: Process exited with status 0
2019-02-09T03:11:20.141798+00:00 heroku[run.6801]: State changed from up to complete
2019-02-09T03:15:30.610720+00:00 heroku[web.1]: State changed from crashed to starting
2019-02-09T06:28:53.311604+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=srms-demo.herokuapp.com request_id=04075507-aa74-4f7b-b303-081b50c4d876 fwd="116.58.205.24" dyno= connect= service= status=503 bytes= protocol=https

Cannot push django app to Heroku

I am trying to deploy a CMS application on Heroku. But when I try
git push heroku master
I am getting the following errors.
Counting objects: 2841, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2775/2775), done.
Writing objects: 100% (2841/2841), 13.35 MiB | 497.00 KiB/s, done.
Total 2841 (delta 917), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing python-3.6.6
remote: -----> Installing pip
remote: -----> Installing requirements with pip
remote: Collecting pkg-resources==0.0.0 (from -r /tmp/build_2e9a3f2d21d5a1b3c5ab348811182510/requirements.txt (line 1))
remote: Could not find a version that satisfies the requirement pkg-resources==0.0.0 (from -r /tmp/build_2e9a3f2d21d5a1b3c5ab348811182510/requirements.txt (line 1)) (from versions: )
remote: No matching distribution found for pkg-resources==0.0.0 (from -r /tmp/build_2e9a3f2d21d5a1b3c5ab348811182510/requirements.txt (line 1))
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to peaceful-olympic-84671.
remote:
To https://git.heroku.com/peaceful-olympic-84671.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/peaceful-olympic-84671.git'
I have already seen many answers to this same question on stack overflow but none of the answers is working for me. Please help.
Update: Removing the pkg-resources from requirements.txt helped. But the application isn't being displayed. It says application errors, check your logs for details.
This is my log file in Heroku.
2018-07-04T13:19:20.003057+00:00 heroku[web.1]: Starting process with command `gunicorn zoomtail.wsgi --log-file -`
2018-07-04T13:19:22.351320+00:00 heroku[web.1]: State changed from starting to crashed
2018-07-04T13:19:22.264506+00:00 app[web.1]: bash: gunicorn: command not found
2018-07-04T13:19:22.329998+00:00 heroku[web.1]: Process exited with status 127
2018-07-04T15:49:08.058951+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=peaceful-olympic-84671.herokuapp.com request_id=b22e6349-7456-4bfe-bb40-7be7b285e027 fwd="106.206.63.203" dyno= connect= service= status=503 bytes= protocol=https
2018-07-04T15:49:08.609553+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=peaceful-olympic-84671.herokuapp.com request_id=cb458cf7-fd71-4342-a3be-e46f258b6072 fwd="106.206.63.203" dyno= connect= service= status=503 bytes= protocol=https
2018-07-04T15:49:44.078076+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=peaceful-olympic-84671.herokuapp.com request_id=a3d03045-0204-44e4-9739-afeaa95eb1d0 fwd="106.206.63.203" dyno= connect= service= status=503 bytes= protocol=https
2018-07-04T15:49:45.057346+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=peaceful-olympic-84671.herokuapp.com request_id=dde12264-b1a6-4394-8427-4f431a292a6c fwd="106.206.63.203" dyno= connect= service= status=503 bytes= protocol=https
2018-07-04T15:52:41.870237+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=peaceful-olympic-84671.herokuapp.com request_id=95caff68-1fc2-4767-a835-e3e51fb867a8 fwd="106.206.63.203" dyno= connect= service= status=503 bytes= protocol=https
2018-07-04T15:52:42.608603+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=peaceful-olympic-84671.herokuapp.com request_id=7b5ad55a-8c59-4c92-8480-a9ed11572306 fwd="106.206.63.203" dyno= connect= service= status=503 bytes= protocol=https
I cannot make sense of the error. Please help.
Remove Following line from requirements.txt before push to heroku.
pkg-resources==0.0.0

heroku $PORT variable in Procfile

Hi have a Django project that I want to deploy on heroku. My procfile looks like this:
web: python subfolder/manage.py runserver $PORT
But my heroku logs tell me that the application did not bind to the port within the required time.
2014-04-17T15:35:20.294741+00:00 heroku[api]: Deploy c456cc6 by my#email.com
2014-04-17T15:35:20.294830+00:00 heroku[api]: Release v17 created by my#email.com
2014-04-17T15:35:31.447035+00:00 heroku[web.1]: Starting process with command `python subfolder/manage.py runserver 14311`
2014-04-17T15:35:32.949252+00:00 app[web.1]: >>> sys.argv: ['subfolder/manage.py', 'runserver', '14311']
2014-04-17T15:35:33.286494+00:00 app[web.1]: >>> sys.argv: ['subfolder/manage.py', 'runserver', '14311']
2014-04-17T15:35:33.296080+00:00 app[web.1]: Validating models...
2014-04-17T15:35:33.296084+00:00 app[web.1]:
2014-04-17T15:35:33.434037+00:00 app[web.1]: 0 errors found
2014-04-17T15:35:33.434129+00:00 app[web.1]: April 17, 2014 - 10:35:33
2014-04-17T15:35:33.434131+00:00 app[web.1]: Django version 1.6.2, using settings 'subfolder.settings'
2014-04-17T15:35:33.434133+00:00 app[web.1]: Starting development server at http://127.0.0.1:14311/
2014-04-17T15:35:33.434134+00:00 app[web.1]: Quit the server with CONTROL-C.
2014-04-17T15:36:31.995497+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2014-04-17T15:36:31.995711+00:00 heroku[web.1]: Stopping process with SIGKILL
2014-04-17T15:36:33.512080+00:00 heroku[web.1]: Process exited with status 137
2014-04-17T15:36:33.526505+00:00 heroku[web.1]: State changed from starting to crashed
2014-04-17T15:36:33.527696+00:00 heroku[web.1]: State changed from crashed to starting
2014-04-17T15:36:42.946854+00:00 heroku[web.1]: Starting process with command `python subfolder/manage.py runserver 9192`
2014-04-17T15:36:43.989111+00:00 app[web.1]: >>> sys.argv: ['subfolder/manage.py', 'runserver', '9192']
2014-04-17T15:36:44.294956+00:00 app[web.1]: >>> sys.argv: ['subfolder/manage.py', 'runserver', '9192']
2014-04-17T15:36:44.302783+00:00 app[web.1]: Validating models...
2014-04-17T15:36:44.302787+00:00 app[web.1]:
2014-04-17T15:36:44.447995+00:00 app[web.1]: 0 errors found
2014-04-17T15:36:44.448008+00:00 app[web.1]: April 17, 2014 - 10:36:44
2014-04-17T15:36:44.448009+00:00 app[web.1]: Django version 1.6.2, using settings 'subfolder.settings'
2014-04-17T15:36:44.448010+00:00 app[web.1]: Starting development server at http://127.0.0.1:9192/
2014-04-17T15:36:44.448012+00:00 app[web.1]: Quit the server with CONTROL-C.
2014-04-17T15:37:43.446630+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2014-04-17T15:37:43.446759+00:00 heroku[web.1]: Stopping process with SIGKILL
2014-04-17T15:37:43.456335+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path=/ host=my-app.herokuapp.com request_id=7eed5b88-2bb3-479e-b268-f538742d8ac9 fwd="91.52.58.207" dyno= connect= service= status=503 bytes=
2014-04-17T15:37:44.608835+00:00 heroku[web.1]: Process exited with status 137
2014-04-17T15:37:44.625259+00:00 heroku[web.1]: State changed from starting to crashed
2014-04-17T15:39:18.516212+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=my-app.herokuapp.com request_id=145aa053-bb2b-4570-8ba6-fa88f2a5b1a6 fwd="91.52.58.207" dyno= connect= service= status=503 bytes=
2014-04-17T15:47:22.827631+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=my-app.herokuapp.com request_id=fe43143f-defd-4756-a61c-e9558dd15ae6 fwd="91.52.58.207" dyno= connect= service= status=503 bytes=
2014-04-17T15:57:27.577848+00:00 heroku[web.1]: State changed from crashed to starting
2014-04-17T15:57:37.742542+00:00 heroku[web.1]: Starting process with command `python subfolder/manage.py runserver 10935`
2014-04-17T15:57:39.224244+00:00 app[web.1]: >>> sys.argv: ['subfolder/manage.py', 'runserver', '10935']
2014-04-17T15:57:39.788496+00:00 app[web.1]: Django version 1.6.2, using settings 'subfolder.settings'
2014-04-17T15
:57:39.788498+00:00 app[web.1]: Starting development server at http://127.0.0.1:10935/
2014-04-17T15:57:39.618885+00:00 app[web.1]: >>> sys.argv: ['subfolder/manage.py', 'runserver', '10935']
2014-04-17T15:57:39.788500+00:00 app[web.1]: Quit the server with CONTROL-C.
2014-04-17T15:57:39.636416+00:00 app[web.1]: Validating models...
2014-04-17T15:57:39.636420+00:00 app[web.1]:
2014-04-17T15:57:39.788202+00:00 app[web.1]: 0 errors found
2014-04-17T15:57:39.788493+00:00 app[web.1]: April 17, 2014 - 10:57:39
2014-04-17T15:58:38.275475+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2014-04-17T15:58:38.275554+00:00 heroku[web.1]: Stopping process with SIGKILL
2014-04-17T15:58:39.572038+00:00 heroku[web.1]: Process exited with status 137
2014-04-17T15:58:39.588577+00:00 heroku[web.1]: State changed from starting to crashed
2014-04-17T16:04:48.672005+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=my-app.herokuapp.com request_id=fc101c45-45c0-4e46-ad26-a7953619525e fwd="91.52.58.207" dyno= connect= service= status=503 bytes=
It seems like $PORT differs from some time to time. The heroku config however says the following:
(.env) $ heroku config
=== my-app Config Vars
PORT: 33507
Why doesn't it work?
By default the development server binds to localhost only, you must specific that you want to bind to any IP:
web: python subfolder/manage.py runserver 0.0.0.0:$PORT
But running the dev server in production is a very bad idea. You really should be using gunicorn or some other proper server to deploy your project:
web: gunicorn subfolder/yourproject.wsgi
Follow the steps on https://devcenter.heroku.com/articles/getting-started-with-django if you need more guidance.

Heroku Django-Admin 500 Error?

Deployed a new app to Heroku app that runs fine at myapp.herokuapp.com, but throws a 500 Server Error if I try to access the admin backend at myapp.herokuapp.com/admin
INSTALLED_APPS = (
...
'django.contrib.admin',
'gunicorn',
'storages',
# 'django.contrib.admindocs',
)
Here's the log excerpt:
2013-07-10T17:35:28.893320+00:00 heroku[web.1]: Starting process with command `python manage.py run_gunicorn -b 0.0.0.0:27294 -w 3 --log-level info`
2013-07-10T17:35:32.298226+00:00 app[web.1]: 2013-07-10 13:35:32 [2] [INFO] Starting gunicorn 0.17.4
2013-07-10T17:35:32.299005+00:00 app[web.1]: 2013-07-10 13:35:32 [2] [INFO] Using worker: sync
2013-07-10T17:35:32.298932+00:00 app[web.1]: 2013-07-10 13:35:32 [2] [INFO] Listening at: http://0.0.0.0:27294 (2)
2013-07-10T17:35:32.312781+00:00 app[web.1]: 2013-07-10 13:35:32 [11] [INFO] Booting worker with pid: 11
2013-07-10T17:35:32.388874+00:00 app[web.1]: 2013-07-10 13:35:32 [12] [INFO] Booting worker with pid: 12
2013-07-10T17:35:32.495370+00:00 heroku[web.1]: State changed from starting to up
2013-07-10T17:35:32.524196+00:00 app[web.1]: 2013-07-10 13:35:32 [13] [INFO] Booting worker with pid: 13
2013-07-10T17:35:59.929850+00:00 heroku[router]: at=info method=GET path=/ host=myapp.herokuapp.com fwd="64.119.130.116" dyno=web.1 connect=0ms service=190ms status=200 bytes=12220
2013-07-10T17:36:04.363323+00:00 heroku[router]: at=info method=GET path=/admin host=myapp.herokuapp.com fwd="64.119.130.116" dyno=web.1 connect=0ms service=4ms status=301 bytes=5
2013-07-10T17:36:04.872523+00:00 heroku[router]: at=info method=GET path=/admin/ host=myapp.herokuapp.com fwd="64.119.130.116" dyno=web.1 connect=0ms service=481ms status=500 bytes=38
What settings would cause the app to run normally but throw a 500 error on /admin? What am I likely overlooking or missing? Thanks.
Thanks to Magnus' recommendation I added sentry to my project and identified a postgres DatabaseError: relation issue due a project app I hadn't successfully migrated on heroku.
Fix just took a fake and completing the rest of the migration.
heroku run python manage.py migrate app 0016 --fake
heroku run python manage.py migrate
You can add free getsentry addon and receive exception traceback remaining in DEBUG=False in production.
You can also setup plain email notification on errors as admin email.
Without any information about error details it will be hard to give you advice.