Home > Back-end >  Heroku H10 error while deploying django app
Heroku H10 error while deploying django app

Time:10-07

The following error shows up every time! Any fixes for the same?

2021-10-07T10:47:31.133956 00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=zturlshortener.herokuapp.com request_id=c2f90e55-52f5-4955-a1d6-4028456cfddb fwd="103.199.173.31" dyno= connect= service= status=503 bytes= protocol=https

Procfile

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

Settings.py

    import os
    from pathlib import Path

    BASE_DIR = Path(__file__).resolve().parent.parent

    DEBUG = False

    ALLOWED_HOSTS = ['127.0.0.1', 'zturlshortener.herokuapp.com']


    INSTALLED_APPS = [
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'UrlShortApp'
    ]

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

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': 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


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

    DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

wsgi.py

    import os

    from django.core.wsgi import get_wsgi_application

    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'UrlShortener.settings.dev')

    application = get_wsgi_application()

CodePudding user response:

Try :

pip install gunicorn

This usually happens due to the missing package: gunicorn in your virtualenv

CodePudding user response:

Did a rookie mistake by not adding whitenoise in requirements.txt!

  • Related