简体   繁体   中英

'at=error code=H10' WHILE DEPLOYING TO HEROKU

So i have a project that i am trying to deploy to heroku and i keep getting the above error, let me share my code and if you need any other part of the code please ask, thank you It shows an application error when i open the app through heroku

first, the heroku logs --tail brings this result

    2021-01-11T13:11:58.739363+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/util.py", line 358, in import_app
2021-01-11T13:11:58.739364+00:00 app[web.1]: mod = importlib.import_module(module)
2021-01-11T13:11:58.739364+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
2021-01-11T13:11:58.739365+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2021-01-11T13:11:58.739365+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
2021-01-11T13:11:58.739366+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
2021-01-11T13:11:58.739366+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
2021-01-11T13:11:58.739366+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
2021-01-11T13:11:58.739367+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 783, in exec_module
2021-01-11T13:11:58.739367+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2021-01-11T13:11:58.739368+00:00 app[web.1]: File "/app/personalgallery/wsgi.py", line 16, in <module>
2021-01-11T13:11:58.739368+00:00 app[web.1]: application = get_wsgi_application()
2021-01-11T13:11:58.739368+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2021-01-11T13:11:58.739369+00:00 app[web.1]: django.setup(set_prefix=False)
2021-01-11T13:11:58.739369+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/__init__.py", line 19, in setup
2021-01-11T13:11:58.739369+00:00 app[web.1]: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2021-01-11T13:11:58.739370+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/conf/__init__.py", line 82, in __getattr__
2021-01-11T13:11:58.739370+00:00 app[web.1]: self._setup(name)
2021-01-11T13:11:58.739374+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/conf/__init__.py", line 69, in _setup
2021-01-11T13:11:58.739374+00:00 app[web.1]: self._wrapped = Settings(settings_module)
2021-01-11T13:11:58.739375+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/conf/__init__.py", line 170, in __init__
2021-01-11T13:11:58.739375+00:00 app[web.1]: mod = importlib.import_module(self.SETTINGS_MODULE)
2021-01-11T13:11:58.739375+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
2021-01-11T13:11:58.739376+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2021-01-11T13:11:58.739376+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
2021-01-11T13:11:58.739377+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
2021-01-11T13:11:58.739377+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
2021-01-11T13:11:58.739377+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
2021-01-11T13:11:58.739378+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 783, in exec_module
2021-01-11T13:11:58.739378+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2021-01-11T13:11:58.739378+00:00 app[web.1]: File "/app/personalgallery/settings.py", line 30, in <module>
2021-01-11T13:11:58.739379+00:00 app[web.1]: SECRET_KEY = config('SECRET_KEY')
2021-01-11T13:11:58.739379+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/decouple.py", line 199, in __call__
2021-01-11T13:11:58.739379+00:00 app[web.1]: return self.config(*args, **kwargs)
2021-01-11T13:11:58.739380+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/decouple.py", line 83, in __call__
2021-01-11T13:11:58.739380+00:00 app[web.1]: return self.get(*args, **kwargs)
2021-01-11T13:11:58.739380+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/decouple.py", line 68, in get
2021-01-11T13:11:58.739381+00:00 app[web.1]: raise UndefinedValueError('{} not found. Declare it as envvar or define a default value.'.format(option))
2021-01-11T13:11:58.739381+00:00 app[web.1]: decouple.UndefinedValueError: SECRET_KEY not found. Declare it as envvar or define a default value.
2021-01-11T13:11:58.739544+00:00 app[web.1]: [2021-01-11 13:11:58 +0000] [9] [INFO] Worker exiting (pid: 9)
2021-01-11T13:11:58.801056+00:00 app[web.1]: [2021-01-11 13:11:58 +0000] [10] [ERROR] Exception in worker process
2021-01-11T13:11:58.801058+00:00 app[web.1]: Traceback (most recent call last):
2021-01-11T13:11:58.801059+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2021-01-11T13:11:58.801060+00:00 app[web.1]: worker.init_process()
2021-01-11T13:11:58.801060+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 119, in init_process
2021-01-11T13:11:58.801060+00:00 app[web.1]: self.load_wsgi()
2021-01-11T13:11:58.801061+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
2021-01-11T13:11:58.801061+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2021-01-11T13:11:58.801062+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
2021-01-11T13:11:58.801062+00:00 app[web.1]: self.callable = self.load()
2021-01-11T13:11:58.801063+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
2021-01-11T13:11:58.801063+00:00 app[web.1]: return self.load_wsgiapp()
2021-01-11T13:11:58.801064+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
2021-01-11T13:11:58.801064+00:00 app[web.1]: return util.import_app(self.app_uri)
2021-01-11T13:11:58.801064+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/util.py", line 358, in import_app
2021-01-11T13:11:58.801065+00:00 app[web.1]: mod = importlib.import_module(module)
2021-01-11T13:11:58.801065+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
2021-01-11T13:11:58.801066+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2021-01-11T13:11:58.801066+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
2021-01-11T13:11:58.801066+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
2021-01-11T13:11:58.801067+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
2021-01-11T13:11:58.801067+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
2021-01-11T13:11:58.801067+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 783, in exec_module
2021-01-11T13:11:58.801068+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2021-01-11T13:11:58.801068+00:00 app[web.1]: File "/app/personalgallery/wsgi.py", line 16, in <module>
2021-01-11T13:11:58.801069+00:00 app[web.1]: application = get_wsgi_application()
2021-01-11T13:11:58.801069+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2021-01-11T13:11:58.801069+00:00 app[web.1]: django.setup(set_prefix=False)
2021-01-11T13:11:58.801070+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/__init__.py", line 19, in setup
2021-01-11T13:11:58.801070+00:00 app[web.1]: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2021-01-11T13:11:58.801070+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/conf/__init__.py", line 82, in __getattr__
2021-01-11T13:11:58.801071+00:00 app[web.1]: self._setup(name)
2021-01-11T13:11:58.801079+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/conf/__init__.py", line 69, in _setup
2021-01-11T13:11:58.801079+00:00 app[web.1]: self._wrapped = Settings(settings_module)
2021-01-11T13:11:58.801079+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/conf/__init__.py", line 170, in __init__
2021-01-11T13:11:58.801080+00:00 app[web.1]: mod = importlib.import_module(self.SETTINGS_MODULE)
2021-01-11T13:11:58.801080+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
2021-01-11T13:11:58.801081+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2021-01-11T13:11:58.801081+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
2021-01-11T13:11:58.801081+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
2021-01-11T13:11:58.801082+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
2021-01-11T13:11:58.801082+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
2021-01-11T13:11:58.801082+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 783, in exec_module
2021-01-11T13:11:58.801083+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2021-01-11T13:11:58.801083+00:00 app[web.1]: File "/app/personalgallery/settings.py", line 30, in <module>
2021-01-11T13:11:58.801083+00:00 app[web.1]: SECRET_KEY = config('SECRET_KEY')
2021-01-11T13:11:58.801084+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/decouple.py", line 199, in __call__
2021-01-11T13:11:58.801084+00:00 app[web.1]: return self.config(*args, **kwargs)
2021-01-11T13:11:58.801085+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/decouple.py", line 83, in __call__
2021-01-11T13:11:58.801085+00:00 app[web.1]: return self.get(*args, **kwargs)
2021-01-11T13:11:58.801085+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/decouple.py", line 68, in get
2021-01-11T13:11:58.801086+00:00 app[web.1]: raise UndefinedValueError('{} not found. Declare it as envvar or define a default value.'.format(option))
2021-01-11T13:11:58.801086+00:00 app[web.1]: decouple.UndefinedValueError: SECRET_KEY not found. Declare it as envvar or define a default value.
2021-01-11T13:11:58.808950+00:00 app[web.1]: [2021-01-11 13:11:58 +0000] [10] [INFO] Worker exiting (pid: 10)
2021-01-11T13:11:59.029033+00:00 app[web.1]: [2021-01-11 13:11:59 +0000] [4] [INFO] Shutting down: Master
2021-01-11T13:11:59.029138+00:00 app[web.1]: [2021-01-11 13:11:59 +0000] [4] [INFO] Reason: Worker failed to boot.
2021-01-11T13:11:59.163235+00:00 heroku[web.1]: Process exited with status 3
2021-01-11T13:11:59.237160+00:00 heroku[web.1]: State changed from up to crashed
2021-01-11T13:12:12.047165+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=personalgalleryapp.herokuapp.com request_id=c8ed4df2-b33b-4644-afe8-fc482c8dc09e fwd="154.123.147.153" dyno= connect= service= status=503 bytes= protocol=https
2021-01-11T13:12:12.756886+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=personalgalleryapp.herokuapp.com request_id=be7fa125-4993-4b05-809e-75e8be4d3bbe fwd="154.123.147.153" dyno= connect= service= status=503 bytes= protocol=https

here is my procfile

web: gunicorn personalgallery.wsgi --log-file -

settings.py

 from pathlib import Path
import os
import django_heroku
import dj_database_url
from decouple import config,Csv


MODE=config("MODE", default="dev")
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!

SECRET_KEY = config('SECRET_KEY')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = config('DEBUG', default=False, cast=bool)

ALLOWED_HOSTS = ['*']


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'bootstrap3',
    'gallery.apps.GalleryConfig',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    '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',
    'whitenoise.middleware.WhiteNoiseMiddleware',
]

ROOT_URLCONF = 'personalgallery.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 = 'personalgallery.wsgi.application'


# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
if config('MODE')=="dev":

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql',
            'NAME': config('DB_NAME'),
            'USER': config('DB_USER'),
            'PASSWORD':config('DB_PASSWORD'),
            'HOST': config('DB_HOST'),
        }
    }

else:
    DATABASES = {
        'default': dj_database_url.config(
            default=config('DATABASE_URL')
        )
    }

db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)

ALLOWED_HOSTS = config('ALLOWED_HOSTS', cast=Csv())

# Password validation
# https://docs.djangoproject.com/en/3.1/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.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Africa/Nairobi'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static"),
]
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

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

# Configure Django App for Heroku.
django_heroku.settings(locals())

In your log you have a line:

decouple.UndefinedValueError: SECRET_KEY not found. Declare it as envvar or define a default value.

This means your SECRET_KEY variable is not recognized, try changing it or make sure that the value is passsed correctly from your config file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM