0
votes

I am trying to deploy API made in Python to to Heroku. I am getting this errors and I do not know how to fix them.

at=error code=H10 desc="App crashed" method=GET path="/" host=pythonapisfind.herokuapp.com request_id=a0e39942-e0d5-4159-87fa-b06e997122b6 fwd="217.97.50.218" dyno= connect= service= status=503 bytes= protocol=https
2020-12-09T09:06:17.055412+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=pythonapisfind.herokuapp.com request_id=b76f9c8c-a187-4516-9338-f01bca9eb726 fwd="217.97.50.218" dyno= connect= service= status=503 bytes= protocol=https
from pathlib import Path
from environ import Env

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

env = Env()
env.read_env(env_file='.env')

SECRET_KEY = env('DJANGO_SECRET_KEY')
DEBUG = env.bool('DJANGO_DEBUG')

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'drf_yasg',
    'corsheaders',
    'rest_framework',

    'apps.core',
    'apps.offers'
]

MIDDLEWARE = [
    'corsheaders.middleware.CorsMiddleware',
    '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',
]

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


# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': env("DATABASE_NAME"),
        'USER': env("DATABASE_USER"),
        'PASSWORD': env("DATABASE_PASSWORD"),
        'HOST': env("DATABASE_HOST"),
        'PORT': env("DATABASE_PORT"),
    }
}


# 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 = 'UTC'

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_URL = '/static/'

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

CORS_ORIGIN_ALLOW_ALL = True

asgiref==3.3.1
certifi==2020.12.5
chardet==3.0.4
coreapi==2.3.3
coreschema==0.0.4
Django==3.1.4
django-cors-headers==3.5.0
django-environ==0.4.5
djangorestframework==3.12.2
drf-yasg==1.20.0
idna==2.10
inflection==0.5.1
itypes==1.2.0
Jinja2==2.11.2
MarkupSafe==1.1.1
packaging==20.7
postgres==3.0.0
psycopg2-binary==2.8.6
psycopg2-pool==1.1
pyparsing==2.4.7
pytz==2020.4
requests==2.25.0
ruamel.yaml==0.16.12
ruamel.yaml.clib==0.2.2
sqlparse==0.4.1
uritemplate==3.0.1
urllib3==1.26.2
gunicorn ==20.0.4

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

enter image description here

1
can you share your Procfile and settings.py ?Eric Martin
I've added to original post.Stackerss
You share your requirements.txt, add your procfile. The rootcause is generally a problem with the procfile. Btw, your procfile is in the root folder ?Eric Martin
Yes in root folder. procfile: web: gunicorn offers.wsgi --log-file -Stackerss
this error occur due to improper/incomplete deployment process. your project haven't build and release properly. so when you access URL without build it's throw this error. there are many configurations before deployment and you have to find exact location which break deployment.Vishal Patel

1 Answers

1
votes

Your wsgi.py had a wrong setting for the settings location

Change

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')

to

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')