简体   繁体   English

将Django部署到Heroku时出现服务器错误500

[英]Server error 500 when deploy django to Heroku

I got following server error 500 when deploying django app to heroku. 将django应用部署到heroku时出现服务器错误500。 I have worked on this problem for 2 days to fix, but have no idea to solve the problems. 我已经解决了2天,但是不知道要解决什么问题。 I assume djangorestframework cause this problems because it has favicon.ico which leads "GET /favicon.ico HTTP/1.1" 404 77" but no idea. 我认为djangorestframework会导致此问题,因为它具有favicon.ico,导致“ GET /favicon.ico HTTP / 1.1” 404 77“,但不知道。

Does anyone detect issues? 有没有人发现问题? Thank you for your support in advance!! 谢谢您的提前支持!

2019-07-23T12:03:44.622777+00:00 app[api]: Release v23 created by user atnihs-do-21@hotmail.co.jp
2019-07-23T12:03:51.865737+00:00 heroku[web.1]: Starting process with command `gunicorn alumate.wsgi --log-file -`
2019-07-23T12:03:55.314454+00:00 heroku[web.1]: State changed from starting to up
2019-07-23T12:03:55.130912+00:00 app[web.1]: [2019-07-23 12:03:55 +0000] [4] [INFO] Starting gunicorn 19.9.0
2019-07-23T12:03:55.132168+00:00 app[web.1]: [2019-07-23 12:03:55 +0000] [4] [INFO] Listening at: http://0.0.0.0:20191 (4)
2019-07-23T12:03:55.132311+00:00 app[web.1]: [2019-07-23 12:03:55 +0000] [4] [INFO] Using worker: sync
2019-07-23T12:03:55.138103+00:00 app[web.1]: [2019-07-23 12:03:55 +0000] [10] [INFO] Booting worker with pid: 10
2019-07-23T12:03:55.150027+00:00 app[web.1]: [2019-07-23 12:03:55 +0000] [11] [INFO] Booting worker with pid: 11
2019-07-23T12:03:55.000000+00:00 app[api]: Build succeeded
2019-07-23T12:04:30.649490+00:00 heroku[router]: at=info method=GET path="/" host=alumate.herokuapp.com request_id=0f1e339a-08fc-4b93-9c1b-1db28b675f76 fwd="210.150.77.215" dyno=web.1 connect=1ms service=835ms status=500 bytes=234 protocol=https
2019-07-23T12:04:30.649933+00:00 app[web.1]: 10.99.197.226 - - [23/Jul/2019:12:04:30 +0000] "GET / HTTP/1.1" 500 27 "https://dashboard.heroku.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36"
2019-07-23T12:04:31.116073+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=alumate.herokuapp.com request_id=381749d5-0137-4017-bd1b-8bb8cb6feef1 fwd="210.150.77.215" dyno=web.1 connect=0ms service=186ms status=404 bytes=258 protocol=https
2019-07-23T12:04:31.116099+00:00 app[web.1]: 10.99.197.226 - - [23/Jul/2019:12:04:31 +0000] "GET /favicon.ico HTTP/1.1" 404 77 "https://alumate.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36"

Settings.py is here Settings.py在这里

import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

SECRET_KEY = 'XXXXXXXXXXXXXXXX'

DEBUG = True

ALLOWED_HOSTS = []

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.humanize',
    'rest_framework',
    'widget_tweaks',
    'boards',
    'accounts',
    'auths',
    'my_universities',
    'my_profiles',
    'universities',
    'charts',
    'storages',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'whitenoise.middleware.WhiteNoiseMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'alumate.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'alumate.wsgi.application'

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


LOGIN_URL = 'login'
LOGIN_REDIRECT_URL = 'home'
LOGOUT_REDIRECT_URL = 'home'


STATIC_URL = '/static/'                                             
STATICFILES_DIRS = [                                                
        os.path.join(BASE_DIR, 'static'),
    ]
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' 


MEDIA_URL = '/media/'                                                
MEDIA_ROOT = os.path.join(BASE_DIR, 'media_root')   


DEBUG = False

try:
    from .local_settings import *
except ImportError:
    pass

    if not DEBUG:
        import django_heroku
        django_heroku.settings(locals())

I deleted image files in static folder and ran python manage.py collectstatic 我删除了静态文件夹中的图像文件并运行python manage.py collectstatic

For the reference to other people who have similar issues, paste the code below to the bottom of settings.py and run heroku logs --tail --all [your app name] after the deployment. 要参考其他有类似问题的人,请将下面的代码粘贴到settings.py的底部,并在部署后运行heroku logs --tail --all [your app name]

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'console': {
            'class': 'logging.StreamHandler',
        },
    },
    'loggers': {
        'django': {
            'handlers': ['console'],
            'level': os.getenv('DJANGO_LOG_LEVEL', 'ERROR'),
        },
    },
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 django 部署到 Heroku:服务器错误 (500) - django deploy to Heroku : Server Error(500) 尝试在 heroku 上使用 DEBUG=False 部署 django 应用程序时出现服务器错误 (500) - Server error (500) when trying to deploy django app with DEBUG=False on heroku 使用Gunicorn和Nginx部署Django时出现500个内部服务器错误 - 500 internal server error when deploy django with gunicorn and nginx 服务器错误 (500) 在 heroku 上部署 Django - Server error (500) Django deployment on heroku 将 Django 部署到 Heroku 会导致服务器错误 (500) - Deploying Django To Heroku gives server error (500) 将 Django 部署到 Heroku - 服务器错误 (500) - Deploying Django To Heroku - Server Error (500) 使用 Heroku 和 Django 时 Debug=False 时出现 500 错误 - 500 error when Debug=False with Heroku and Django 每当django中debug = False时,Heroku会显示Server Error(500),而debug = True no error时 - Whenever debug=False in django, Heroku gives Server Error (500) and when debug=True no error 当 debug 设置为 False 时,在 Heroku 上部署 Django 时出现服务器错误 500 - Server error 500 on Django when deployed on Heroku when debug is set to False 服务器错误 (500) 在部署 Heroku 的 Django 项目时出现密码重置请求 - Server Error (500) On Password Reset Request when deployed Django Project at Heroku
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM