Z
Z
Zuzupoj2020-04-26 19:15:32
Python
Zuzupoj, 2020-04-26 19:15:32

Why is heroku throwing a 500 error?

I deployed a site on heroku, but when I try to go to it, I get a Server Error (500).
How to find out what's wrong? And where in general to drip?

update:
Logs from bash heroku:

2020-04-26T16:54:47.386936+00:00 app[web.1]: [2020-04-26 16:54:47 +0000] [11] [INFO] Worker exiting (pid: 11)
2020-04-26T16:54:47.386942+00:00 app[web.1]: [2020-04-26 16:54:47 +0000] [10] [INFO] Worker exiting (pid: 10)
2020-04-26T16:54:47.386943+00:00 app[web.1]: [2020-04-26 16:54:47 +0000] [4] [INFO] Handling signal: term
2020-04-26T16:54:47.487627+00:00 app[web.1]: [2020-04-26 16:54:47 +0000] [4] [INFO] Shutting down: Master
2020-04-26T16:54:53.176427+00:00 app[web.1]: [2020-04-26 16:54:53 +0000] [4] [INFO] Starting gunicorn 20.0.4
2020-04-26T16:54:53.176945+00:00 app[web.1]: [2020-04-26 16:54:53 +0000] [4] [INFO] Listening at: http://0.0.0.0:48342 (4)
2020-04-26T16:54:53.177042+00:00 app[web.1]: [2020-04-26 16:54:53 +0000] [4] [INFO] Using worker: sync
2020-04-26T16:54:53.180869+00:00 app[web.1]: [2020-04-26 16:54:53 +0000] [10] [INFO] Booting worker with pid: 10
2020-04-26T16:54:53.204875+00:00 app[web.1]: [2020-04-26 16:54:53 +0000] [11] [INFO] Booting worker with pid: 11
2020-04-26T16:54:53.865350+00:00 heroku[web.1]: State changed from starting to up
2020-04-26T16:54:55.000000+00:00 app[api]: Build succeeded
2020-04-26T16:55:13.344792+00:00 app[web.1]: 10.142.64.122 - - [26/Apr/2020:16:55:13 +0000] "GET /reviews/ HTTP/1.1" 500 145 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0"
2020-04-26T16:55:13.344461+00:00 heroku[router]: at=info method=GET path="/reviews/" host=prqy.herokuapp.com request_id=98503209-aecc-46cb-abd1-a0f7a7870e07 fwd="188.32.33.3" dyno=web.1 connect=0ms service=145ms status=500 bytes=380 protocol=https

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
Zuzupoj, 2020-04-29
@Zuzupoj

It wasn't easy, but I did it. On the computer in the project:
settings.py

import django_heroku
Debug =  bool( os.environ.get('DJANGO_DEBUG', False) )
ALLOWED_HOSTS = ['*']
MIDDLEWARE = [
    'whitenoise.middleware.WhiteNoiseMiddleware', #Добавляем до 'django.middleware.security.SecurityMiddleware',
]

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = '[email protected]' #С которого будет приходить сообщение
EMAIL_HOST_PASSWORD = 'password'
EMAIL_PORT = 587

ADMINS = [
    (''Name, '[email protected]'),
]
WHITENOISE_USE_FINDERS = True
STATIC_ROOT = None
django_heroku.settings(locals()) #В конце

The problem was in static files. But when the server is turned on with DEBUG = False, you won’t know about it until you set up mail, because with DEBUG = False it will send you information about errors to the mail specified in ADMINS. To solve the problem with statics, I used whitenoise (You can dig up the information in Google). Since I decided not to bother with statics further, I set STATIC_ROOT = none, and now whitenoise was looking for statics as a built-in application 'django.contrib.staticfiles', (by the way, I cut it too, because statics are searched without it). The problem remained that it found the static folder in the project's applications, but did not look in its nested folder, so I just moved all the statics to one place, namely static (no subfolders)
Maybe I'm not very accurate somewhere, but at least you will see the logs with DEBUG = False, and then decide everything according to the thumb.

Y
yyyakovlev, 2020-05-01
@yyyakovlev

Does everything work locally? Then I propose to check the spelling of the paths. This heroku junga is damn case sensitive: jpg\JPG, mp4\MP4. In your case it might be html\HTML. Thus, it considers that PHOTO.JPG, photo.JPG, photo.jpg are three different files. It helped me. Sorry, if not in this, the amateur himself)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question