Heroku Django-Admin 500 Error? - django

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.

Related

Heroku build django app doesn't create STATIC_ROOT dir if DEBUG=False. Why, what goes up in there?

Dajango (+channels/postgres/redis) app on heroku with DEBUG=True works well, no errors, no abnormalities. If DEBUG=False then it actually doesn't work at all, error500. Some clue how DEBUG flag can be involved in a way like that? Thank you.
Heroku Log Example, DEBUG=True (works OK):
GET path="/"
"GET / HTTP/1.1" 302
"GET /accounts/login/?next=/ HTTP/1.1" 200
2020-07-23T16:14:24.496575+00:00 heroku[router]: at=info method=GET path="/" host=immense-escarpment-72885.herokuapp.com request_id=78bccd24-e86e-481f-995e-0aa31b2e440d fwd="68.14.159.220" dyno=web.1 connect=1ms service=117ms status=302 bytes=240 protocol=https
2020-07-23T16:14:24.495692+00:00 app[web.1]: 68.14.159.220:0 - "GET / HTTP/1.1" 302
2020-07-23T16:14:24.705467+00:00 app[web.1]: 68.14.159.220:0 - "GET /accounts/login/?next=/ HTTP/1.1" 200
login page is displayed, OK.
Now the problem: only difference is DEBUG=False:
GET path="/"
UserWarning: No directory at: /app/pickupteaming/staticfiles/
"GET / HTTP/1.1" 302
"GET /accounts/login/?next=/ HTTP/1.1" 500
Heroku Log Example detailed below:
2020-07-23T16:17:32.649059+00:00 heroku[router]: at=info method=GET path="/" host=immense-escarpment-72885.herokuapp.com request_id=22b8a783-04e8-4fda-a185-f0f39c69125e fwd="68.14.159.220" dyno=web.1 connect=0ms service=125ms status=302 bytes=240 protocol=https
2020-07-23T16:17:32.527579+00:00 app[web.1]: /app/.heroku/python/lib/python3.7/site-packages/whitenoise/base.py:116: UserWarning: No directory at: /app/pickupteaming/staticfiles/
2020-07-23T16:17:32.527606+00:00 app[web.1]: warnings.warn(u"No directory at: {}".format(root))
2020-07-23T16:17:32.643881+00:00 app[web.1]: 68.14.159.220:0 - "GET / HTTP/1.1" 302
2020-07-23T16:17:32.733941+00:00 app[web.1]: 68.14.159.220:0 - "GET /accounts/login/?next=/ HTTP/1.1" 500
2020-07-23T16:17:32.739475+00:00 heroku[router]: at=info method=GET path="/accounts/login/?next=/" host=immense-escarpment-72885.herokuapp.com request_id=991497fb-57f9-42f6-ae6b-c4a85dcdc79c fwd="68.14.159.220" dyno=web.1 connect=0ms service=60ms status=500 bytes=353 protocol=https
When you set DEBUG=FALSE you are setting into production mode and Django won't serve your static file the same way like in development mode, as it is inefficient and insecure. You need to install WhiteNoise and do some ajustments on your setting.py file. Check this excellent guide by Mozilla

deploy Django2 on heroku , but can not open the webpage in browsers

I did a django project on python, and push it to heroku, but when I try to access it with
https://desolate-oasis-71960.herokuapp.com
browser can not load it.
I use django2.1.3 on python3, here is my settings.py:
import os
import django_heroku
# Build paths inside the project like this:os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
--snip-
# Activate Django-Heroku.
django_heroku.settings(locals())
#setting Heroku
cwd = os.getcwd()
if cwd == '/app' or cwd[:4] == '/tmp':
import dj_database_url
DATABASES= {
'default': dj_database_url.config(default='postgres://localhost')
}
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO','https')
#ALLOWED_HOSTS = ['*']
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR,'static'),
)
but after I push the project to heroku ,I can not open the webpage, then I run the command: heroku logs, here is the log :
2018-11-16T03:47:55.000000+00:00 app[api]: Build succeeded
2018-11-16T03:48:48.803513+00:00 heroku[router]: at=error code=H14
desc="No web processes running" method=GET path="/"
host=desolate-oasis-71960.herokuapp.com
request_id=703f8297-76f6-4434-9fcc-805c059fd3d8
fwd="202.119.45.10" dyno= connect= service=status=503
bytes=protocol=https
and I also try to load it locally with command
heroku local
the command window always shows like this:
2:52:27 PM web.1 | [2018-11-16 14:52:27 +0800] [1950] [INFO] Starting
gunicorn 19.9.0
2:52:27 PM web.1 | [2018-11-16 14:52:27 +0800] [1950] [INFO] Listening
at: http://0.0.0.0:5000 (1950)
2:52:27 PM web.1 | [2018-11-16 14:52:27 +0800] [1950] [INFO] Using worker: sync
2:52:27 PM web.1 | [2018-11-16 14:52:27 +0800] [1953] [INFO] Booting
worker with pid: 1953
and I need to push "control"+"C" to exit
Help me please
In settings.py:
ALLOWED_HOSTS = ['desolate-oasis-71960.herokuapp.com']
Thanks, I have solved this by re-building Procfile by using command in terminator:
touch .Procfile
and I delete my .git file(have to delete this file),
then re-initialize .git file by command
git init
and it worked.

Docker-compose + Heroku + Django + Gunicorn H14 error

I am getting an H14 Heroku error when trying to deploy my built docker image to heroku.
Since the Heroku documentation says a CMD command is required and it appears that the commands in the Procfile are not actually run I am at a bit of a loss as to what to do.
My heroku error log : `
2017-11-01T11:19:47.714787+00:00 app[globus.1]: Post-processed 'admin/css/forms.css' as 'admin/css/forms.2003a066ae02.css'
2017-11-01T11:19:47.715387+00:00 app[globus.1]:
2017-11-01T11:19:47.715389+00:00 app[globus.1]: 0 static files copied to '/globus/staticfiles', 62 unmodified, 24 post-processed.
2017-11-01T11:20:48.337975+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=kolland-globus-1.herokuapp.com request_id=e2a6eda9-e2bf-477b-9987-b5995d110b0e fwd="2.87.181.37" dyno= connect= service= status=503 bytes= protocol=https
2017-11-01T11:20:48.683132+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=kolland-globus-1.herokuapp.com request_id=eb2e00ee-826a-4ddd-aa22-78e242612e8f fwd="2.87.181.37" dyno= connect= service= status=503 bytes= protocol=https
2017-11-01T11:20:48.766644+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=kolland-globus-1.herokuapp.com request_id=60d645a6-8657-4236-80d9-7a8f8e880640 fwd="2.87.181.37" dyno= connect= service= status=503 bytes= protocol=https
Output of heroku ps:
=== globus (Free): /start.sh (1)
globus.1: up 2017/11/01 13:19:44 +0200 (~ 17m ago)
Heroku Control Panel for the app says:
globus /start.sh
My code is as follows:
1) The start.sh script:
#!/bin/bash
python manage.py migrate # Apply database migrations
python manage.py collectstatic --clear --noinput # clearstatic files
python manage.py collectstatic --noinput # collect static files
# Prepare log files and start outputting logs to stdout
exec gunicorn globus.wsgi --bind 0.0.0.0:$PORT --workers 3
#python manage.py runserver 0.0.0.0:$PORT --settings=globus.settings.production
2) The docker-compose file :
version: '2'
services:
globus:
build: .
image: globus:latest
ports:
- "5000:5000"
env_file: .env
volumes:
- ./globus:/opt/globus
3) Dockerfile:
FROM python:2.7.14
ENV PYTHONUNBUFFERED 1
ADD ./requirements.txt /requirements.txt
ADD ./start.sh /start.sh
ADD . /globus
RUN pip install -r requirements.txt
RUN groupadd -r django && useradd -r -g django django
RUN chown -R django /globus && chmod +x start.sh && chown django start.sh
WORKDIR /globus
CMD ["/start.sh"]
What I've tried ::
CMD [ "python", "./manage.py", "runserver", "0.0.0.0:$PORT", "--settings=globus.settings.production" ]
CMD ["exec", "gunicorn", "globus.wsgi", "-b", "0.0.0.0:$PORT", "--log-file", "-"]
CMD exec gunicorn globus.wsgi -b 0.0.0.0:$PORT --log-file -
CMD ["/start.sh"]
&& ENTRYPOINT ["/start.sh"](without exec gunicorn cmd) + CMD exec gunicorn globus.wsgi -b 0.0.0.0:$PORT
Additionally I've run in the docker-compose file:
command: python manage.py runserver 0.0.0.0:$PORT --settings=globus.settings.production
command: python manage.py makemigrations && python manage.py migrate && python manage.py collectstatic && python manage.py runserver 0.0.0.0:$PORT --settings=globus.settings.production
Notes:
**
Running docker-compose build + up locally works for all aforementioned aproaches provided I change $PORT to 5000.
**
I have a feeling it might have something to do with permissions because I am running docker-compose build + up as root user although am not sure how to change the Dockerfile to avoid that beyond the two lines I have added.
dyno= connect= service= in the error logs I believe means that the app is somehow either crashing or not exposed to the heroku router.
The databse is the Heroku Postgresql Addon and the credentials are stored in an env file. The addon works even if I run docker-compose up on my local machine.
I have a working heroku app that was deployed via git.
When I did an:
heroku run bash
> ls
I could see the file structure
When I do the same on for this app I get nothing
Any help would be greatly appreciated!!!
Result of the Netstat command:
2017-11-01T20:50:11.186705+00:00 app[globus.1]: [2017-11-01 20:50:11 +0000] [6] [INFO] Starting gunicorn 19.7.1
2017-11-01T20:50:11.187111+00:00 app[globus.1]: [2017-11-01 20:50:11 +0000] [6] [INFO] Listening at: http://0.0.0.0:18815 (6)
2017-11-01T20:50:11.202914+00:00 app[globus.1]: [2017-11-01 20:50:11 +0000] [12] [INFO] Booting worker with pid: 12
2017-11-01T20:50:11.187194+00:00 app[globus.1]: [2017-11-01 20:50:11 +0000] [6] [INFO] Using worker: sync
2017-11-01T20:50:11.192252+00:00 app[globus.1]: [2017-11-01 20:50:11 +0000] [11] [INFO] Booting worker with pid: 11
2017-11-01T20:50:11.247884+00:00 app[globus.1]: [2017-11-01 20:50:11 +0000] [13] [INFO] Booting worker with pid: 13
2017-11-01T20:50:16.019831+00:00 heroku[globus.1]: Process exited with status 0
2017-11-01T20:50:15.952136+00:00 app[globus.1]: (Not all processes could be identified, non-owned process info
2017-11-01T20:50:15.957398+00:00 app[globus.1]: Active Internet connections (servers and established)
2017-11-01T20:50:15.957400+00:00 app[globus.1]: Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
2017-11-01T20:50:15.952156+00:00 app[globus.1]: will not be shown, you would have to be root to see it all.)
2017-11-01T20:50:15.957400+00:00 app[globus.1]: tcp 0 0 0.0.0.0:18815 0.0.0.0:* LISTEN 6/python
2017-11-01T20:50:16.031459+00:00 heroku[globus.1]: State changed from up to crashed
2017-11-01T20:51:19.828010+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=kolland-globus-1.herokuapp.com request_id=59003956-da54-4a6f-921f-70ed4930fc3e fwd="2.87.181.37" dyno= connect= service= status=503 bytes= protocol=https
2017-11-01T20:51:19.652507+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=kolland-globus-1.herokuapp.com request_id=6a090f48-214f-457b-9471-09e2995817fe fwd="2.87.181.37" dyno= connect= service= status=503 bytes= protocol=https

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

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.

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.