Мой веб-сайт и страница администратора работают локально, но я получаю сообщение об ошибке приложения: H13 при попытке доступа к моей странице администратора на веб-странице Heroku.
Вот часть журналов heroku:
[web.1]: 10.47.180.171 - - [29/Feb/2020:21:10:30 +0000] "GET /favicon.ico HTTP/1.1" 404 179 "https://quiet-woodland-94985.herokuapp.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36"
2020-02-29T21:18:46.170318+00:00 app[web.1]: [2020-02-29 21:18:46 +0000] [13] [INFO] Booting worker with pid: 13
2020-02-29T21:18:46.166523+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/admin/" host=quiet-woodland-94985.herokuapp.com request_id=43137702-84dc-4892-b3bf-9c0c6d155a6b fwd="174.55.195.195" dyno=web.1 connect=1ms service=67ms status=503 bytes=0 protocol=https
2020-02-29T21:18:56.996229+00:00 app[api]: Set DJANGO_ADMIN_URL config vars by user phikhant@uci.edu
2020-02-29T21:18:56.996229+00:00 app[api]: Release v22 created by user phikhant@uci.edu
2020-02-29T21:18:57.341490+00:00 heroku[web.1]: Restarting
2020-02-29T21:18:57.344662+00:00 heroku[web.1]: State changed from up to starting
2020-02-29T21:18:58.324719+00:00 app[web.1]: [2020-02-29 21:18:58 +0000] [13] [INFO] Worker exiting (pid: 13)[2020-02-29 21:18:58 +0000] [12] [INFO] Worker exiting (pid: 12)
2020-02-29T21:18:58.324729+00:00 app[web.1]:
2020-02-29T21:18:58.324730+00:00 app[web.1]: [2020-02-29 21:18:58 +0000] [4] [INFO] Handling signal: term
2020-02-29T21:18:58.420449+00:00 app[web.1]: [2020-02-29 21:18:58 +0000] [4] [INFO] Shutting down: Master
2020-02-29T21:18:58.304389+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-02-29T21:18:58.508719+00:00 heroku[web.1]: Process exited with status 0
2020-02-29T21:19:01.612316+00:00 heroku[web.1]: Starting process with command `gunicorn TreatmentPlanning.wsgi --log-file -`
2020-02-29T21:19:03.436411+00:00 app[web.1]: [2020-02-29 21:19:03 +0000] [4] [INFO] Starting gunicorn 20.0.4
2020-02-29T21:19:03.436964+00:00 app[web.1]: [2020-02-29 21:19:03 +0000] [4] [INFO] Listening at: http://0.0.0.0:59479 (4)
2020-02-29T21:19:03.437062+00:00 app[web.1]: [2020-02-29 21:19:03 +0000] [4] [INFO] Using worker: sync
2020-02-29T21:19:03.441089+00:00 app[web.1]: [2020-02-29 21:19:03 +0000] [10] [INFO] Booting worker with pid: 10
2020-02-29T21:19:03.500564+00:00 app[web.1]: [2020-02-29 21:19:03 +0000] [11] [INFO] Booting worker with pid: 11
2020-02-29T21:19:03.877103+00:00 heroku[web.1]: State changed from starting to up
2020-02-29T21:19:06.855573+00:00 app[web.1]: [2020-02-29 21:19:06 +0000] [12] [INFO] Booting worker with pid: 12
2020-02-29T21:19:06.852571+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/admin/" host=quiet-woodland-94985.herokuapp.com request_id=ba1359d8-8365-4e35-bc10-93f902e33ee5 fwd="174.55.195.195" dyno=web.1 connect=1ms service=117ms status=503 bytes=0 protocol=https
2020-02-29T21:21:16.208007+00:00 app[api]: Starting process with command `bash` by user phikhant@uci.edu
2020-02-29T21:21:22.007938+00:00 heroku[run.3168]: State changed from starting to up
2020-02-29T21:21:22.178709+00:00 heroku[run.3168]: Awaiting client
2020-02-29T21:21:22.214591+00:00 heroku[run.3168]: Starting process with command `bash`
2020-02-29T21:21:58.055564+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/admin/" host=quiet-woodland-94985.herokuapp.com request_id=b67d0ddd-d88d-4c39-9cca-15c27ea7cc16 fwd="174.55.195.195" dyno=web.1 connect=1ms service=106ms status=503 bytes=0 protocol=https
2020-02-29T21:21:58.058202+00:00 app[web.1]: [2020-02-29 21:21:58 +0000] [13] [INFO] Booting worker with pid: 13
2020-02-29T21:22:00.518484+00:00 heroku[router]: at=info method=GET path="/" host=quiet-woodland-94985.herokuapp.com request_id=b8f0acaf-c2f4-4260-82cf-5f900673d1c7 fwd="174.55.195.195" dyno=web.1 connect=1ms service=63ms status=200 bytes=4899 protocol=https
2020-02-29T21:22:00.511031+00:00 app[web.1]: 10.30.127.176 - - [29/Feb/2020:21:22:00 +0000] "GET / HTTP/1.1" 200 4681 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36"
2020-02-29T21:22:02.627781+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/admin/" host=quiet-woodland-94985.herokuapp.com request_id=f722da7b-00d9-46e7-9e78-20d1e098d11c fwd="174.55.195.195" dyno=web.1 connect=1ms service=95ms status=503 bytes=0 protocol=https
2020-02-29T21:22:02.631308+00:00 app[web.1]: [2020-02-29 21:22:02 +0000] [14] [INFO] Booting worker with pid: 14
2020-02-29T21:22:04.932431+00:00 heroku[run.3168]: Client connection closed. Sending SIGHUP to all processes
2020-02-29T21:22:05.499704+00:00 heroku[run.3168]: State changed from up to complete
2020-02-29T21:22:05.483859+00:00 heroku[run.3168]: Process exited with status 129
Вот мой requirements.txt
файл:
asgiref==3.2.3
dj-database-url==0.5.0
Django==3.0.3
django-heroku==0.3.1
gunicorn==20.0.4
psycopg2==2.8.4
pytz==2019.3
sqlparse==0.3.0
whitenoise==5.0.1
psycopg2-binary==2.8.4
А вот мой procfile
web: gunicorn TreatmentPlanning.wsgi --log-file -
РЕДАКТИРОВАТЬ:
Пока ковыряешься, Я обнаружил, что эта ошибка приложения появляется только после входа в систему. Целевая страница администратора django по-прежнему работает правильно.
Settings.py:
"""
Django settings for TreatmentPlanning project.
Generated by 'django-admin startproject' using Django 3.0.3.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""
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__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ['DJANGO_SECRET_KEY']
# SECURITY WARNING: don't run with debug turned on in production!
# DEBUG = True
DEBUG = os.environ.get('DJANGO_DEBUG', '') != 'False'
ALLOWED_HOSTS = ['quiet-woodland-94985.herokuapp.com' , '127.0.0.1']
# Application definition
INSTALLED_APPS = [
'treatment_plan.apps.TreatmentPlanConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
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 = 'TreatmentPlanning.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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 = 'TreatmentPlanning.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
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',
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Heroku: Update database configuration from $DATABASE_URL.
import dj_database_url
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
# The absolute path to the directory where collectstatic will collect static files for deployment.
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
# The URL to use when referring to static files (where they will be served from)
STATIC_URL = '/static/'
# Simplified static file serving.
# https://warehouse.python.org/project/whitenoise/
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
django_heroku.settings(locals())
url.py в папке проекта
"""TreatmentPlanning URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include("treatment_plan.urls")),
]