Im trying to deploy a django site using Heroku and I keep running into this error when the page tries to load
with heroku logs --tail
» Warning: heroku update available from 7.53.0 to 7.60.2.
2022-05-18T01:09:37.493808+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
2022-05-18T01:09:37.493808+00:00 app[web.1]: worker.init_process()
2022-05-18T01:09:37.493808+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 134, in init_process
2022-05-18T01:09:37.493809+00:00 app[web.1]: self.load_wsgi()
2022-05-18T01:09:37.493809+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
2022-05-18T01:09:37.493810+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2022-05-18T01:09:37.493810+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi
2022-05-18T01:09:37.493810+00:00 app[web.1]: self.callable = self.load()
2022-05-18T01:09:37.493811+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
2022-05-18T01:09:37.493811+00:00 app[web.1]: return self.load_wsgiapp()
2022-05-18T01:09:37.493811+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2022-05-18T01:09:37.493812+00:00 app[web.1]: return util.import_app(self.app_uri)
2022-05-18T01:09:37.493812+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/util.py", line 359, in import_app
2022-05-18T01:09:37.493812+00:00 app[web.1]: mod = importlib.import_module(module)
2022-05-18T01:09:37.493813+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module
2022-05-18T01:09:37.493813+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2022-05-18T01:09:37.493813+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
2022-05-18T01:09:37.493814+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
2022-05-18T01:09:37.493814+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
2022-05-18T01:09:37.493814+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
2022-05-18T01:09:37.493815+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 850, in exec_module
2022-05-18T01:09:37.493815+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
2022-05-18T01:09:37.493815+00:00 app[web.1]: File "/app/GroomingService/GroomingService/wsgi.py", line 16, in <module>
2022-05-18T01:09:37.493816+00:00 app[web.1]: application = get_wsgi_application()
2022-05-18T01:09:37.493816+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2022-05-18T01:09:37.493816+00:00 app[web.1]: django.setup(set_prefix=False)
2022-05-18T01:09:37.493817+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
2022-05-18T01:09:37.493817+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS)
2022-05-18T01:09:37.493818+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/django/apps/registry.py", line 91, in populate
2022-05-18T01:09:37.493818+00:00 app[web.1]: app_config = AppConfig.create(entry)
2022-05-18T01:09:37.493818+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/django/apps/config.py", line 223, in create
2022-05-18T01:09:37.493819+00:00 app[web.1]: import_module(entry)
2022-05-18T01:09:37.493819+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module
2022-05-18T01:09:37.493819+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2022-05-18T01:09:37.493820+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
2022-05-18T01:09:37.493820+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
2022-05-18T01:09:37.493820+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
2022-05-18T01:09:37.493821+00:00 app[web.1]: ModuleNotFoundError: No module named 'appointmentApp'
2022-05-18T01:09:37.493884+00:00 app[web.1]: [2022-05-17 18:09:37 -0700] [10] [INFO] Worker exiting (pid: 10)
2022-05-18T01:09:37.493951+00:00 app[web.1]: [2022-05-17 18:09:37 -0700] [9] [INFO] Worker exiting (pid: 9)
2022-05-18T01:09:37.553717+00:00 heroku[web.1]: State changed from starting to up
2022-05-18T01:09:37.553815+00:00 app[web.1]: Traceback (most recent call last):
2022-05-18T01:09:37.553820+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 209, in run
2022-05-18T01:09:37.554025+00:00 app[web.1]: self.sleep()
2022-05-18T01:09:37.554037+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 357, in sleep
2022-05-18T01:09:37.554155+00:00 app[web.1]: ready = select.select([self.PIPE[0]], [], [], 1.0)
2022-05-18T01:09:37.554157+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
2022-05-18T01:09:37.554242+00:00 app[web.1]: self.reap_workers()
2022-05-18T01:09:37.554243+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2022-05-18T01:09:37.554366+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2022-05-18T01:09:37.554411+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2022-05-18T01:09:37.554413+00:00 app[web.1]:
2022-05-18T01:09:37.554413+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2022-05-18T01:09:37.554413+00:00 app[web.1]:
2022-05-18T01:09:37.554415+00:00 app[web.1]: Traceback (most recent call last):
2022-05-18T01:09:37.554423+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 642, in kill_worker
2022-05-18T01:09:37.554565+00:00 app[web.1]: os.kill(pid, sig)
2022-05-18T01:09:37.554588+00:00 app[web.1]: ProcessLookupError: [Errno 3] No such process
2022-05-18T01:09:37.554590+00:00 app[web.1]:
2022-05-18T01:09:37.554590+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2022-05-18T01:09:37.554590+00:00 app[web.1]:
2022-05-18T01:09:37.554591+00:00 app[web.1]: Traceback (most recent call last):
2022-05-18T01:09:37.554600+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn", line 8, in <module>
2022-05-18T01:09:37.554663+00:00 app[web.1]: sys.exit(run())
2022-05-18T01:09:37.554671+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 67, in run
2022-05-18T01:09:37.554736+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2022-05-18T01:09:37.554743+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 231, in run
2022-05-18T01:09:37.554825+00:00 app[web.1]: super().run()
2022-05-18T01:09:37.554833+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 72, in run
2022-05-18T01:09:37.554896+00:00 app[web.1]: Arbiter(self).run()
2022-05-18T01:09:37.554897+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 229, in run
2022-05-18T01:09:37.554979+00:00 app[web.1]: self.halt(reason=inst.reason, exit_status=inst.exit_status)
2022-05-18T01:09:37.554981+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 342, in halt
2022-05-18T01:09:37.555076+00:00 app[web.1]: self.stop()
2022-05-18T01:09:37.555084+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 390, in stop
2022-05-18T01:09:37.555186+00:00 app[web.1]: self.kill_workers(sig)
2022-05-18T01:09:37.555187+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 632, in kill_workers
2022-05-18T01:09:37.555323+00:00 app[web.1]: self.kill_worker(pid, sig)
2022-05-18T01:09:37.555325+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 644, in kill_worker
2022-05-18T01:09:37.555460+00:00 app[web.1]: if e.errno == errno.ESRCH:
2022-05-18T01:09:37.555462+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
2022-05-18T01:09:37.555542+00:00 app[web.1]: self.reap_workers()
2022-05-18T01:09:37.555551+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2022-05-18T01:09:37.555663+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2022-05-18T01:09:37.555693+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2022-05-18T01:09:37.697703+00:00 heroku[web.1]: Process exited with status 1
2022-05-18T01:09:37.764077+00:00 heroku[web.1]: State changed from up to crashed
2022-05-18T01:09:51.528658+00:00 app[api]: Set maintenance mode off by user danccoral#hotmail.com
2022-05-18T01:10:13.487012+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=elizabethselegantdoggrooming.herokuapp.com request_id=3f02a257-18d8-438d-bcac-778254354ad4 fwd="139.182.209.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-18T01:10:14.027724+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=elizabethselegantdoggrooming.herokuapp.com request_id=f61fe659-2371-48f5-9c94-87339a85b363 fwd="139.182.209.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-18T01:10:29.138152+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=elizabethselegantdoggrooming.herokuapp.com request_id=4ef2c6f9-ef8b-4798-a310-8c76e305d2eb fwd="139.182.209.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-18T01:10:29.502227+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=elizabethselegantdoggrooming.herokuapp.com request_id=84e71487-1c60-4024-b27f-37f24a8bf6c6 fwd="139.182.209.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-18T01:12:44.961980+00:00 app[api]: Starting process with command `printenv` by user danccoral#hotmail.com
2022-05-18T01:12:51.062148+00:00 heroku[run.5944]: Awaiting client
2022-05-18T01:12:51.079149+00:00 heroku[run.5944]: Starting process with command `printenv`
2022-05-18T01:12:51.186266+00:00 heroku[run.5944]: State changed from starting to up
2022-05-18T01:12:54.516779+00:00 heroku[run.5944]: Process exited with status 0
2022-05-18T01:12:54.655109+00:00 heroku[run.5944]: State changed from up to complete
2022-05-18T01:31:48.081568+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=elizabethselegantdoggrooming.herokuapp.com request_id=a13a7884-78a3-461e-be0e-f047d101ffd3 fwd="139.182.209.45" dyno= connect= service= status=503 bytes= protocol=https
2022-05-18T01:31:48.450104+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=elizabethselegantdoggrooming.herokuapp.com request_id=9473141e-ed72-4fb5-8c9b-9264f9b7f42f fwd="139.182.209.45" dyno= connect= service= status=503 bytes= protocol=https
the two most notable things I could find from this error list were
2022-05-18T01:09:37.493821+00:00 app[web.1]: ModuleNotFoundError: No module named 'appointmentApp'
and
2022-05-18T01:09:37.554411+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
I know that with error H10 there might be something wrong with my procfile
web: gunicorn GroomingService.GroomingService.wsgi
My project file struture
Project/
GroomingService/
accountApp/
adminApp/
appointmentApp/
GroomingService/
__pycache__
_init_.py
asagi.py
settings.py
urls.py
views.py
wsgi.py
loginApp/
static/
staticfiles/
templates/
.env
.gitattributes
Procfile
README.md
requirements.txt
runtime.txt
Earlier I was also having trouble because it was telling me that
wsgi could not found
No module named 'GroomingService.wsgi'
and then that settings could not be found
Because of that I added an extra GroomingService to the file path so that it could find it in both my Procfile and my wsgifile
#wsgi.py
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'GroomingService.GroomingService.settings')
application = get_wsgi_application()
procfile
web: gunicorn GroomingService.GroomingService.wsgi
requirements.txt
asgiref==3.5.0
dj-database-url==0.5.0
Django==4.0.1
django-activeurl==0.2.0
django-appconf==1.0.5
django-classy-tags==3.0.1
django-crispy-forms==1.14.0
django-environ==0.8.1
django-heroku==0.3.1
gunicorn==20.1.0
lxml==4.8.0
psycopg2==2.9.3
python-decouple==3.6
python-dotenv==0.20.0
sqlparse==0.4.2
tzdata==2021.5
whitenoise==6.1.0
runtime.txt
python-3.9.12
Edit:
settings.py
from pathlib import Path
import os
from decouple import config
# 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/4.0/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 = False
ALLOWED_HOSTS = ['elizabethselegantdoggrooming.herokuapp.com/', '127.0.0.1', 'elizabethselegantdoggrooming.com']
#is used for crispyforms?
CRISPY_TEMPLATE_PACK = 'bootstrap5'
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
#django apps
'crispy_forms',
'appointmentApp',
'loginApp',
'accountApp',
'adminApp',
]
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 = 'GroomingService.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 = 'GroomingService.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/4.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/4.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'America/Los_Angeles'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = 'static/'
STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), )
# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
#csrf
CSRF_COOKIE_SECURE = True
SESSION_COOKIE_SECURE = True
SECURE_SSL_REDIRECT = True
How can I direct it to find the modules?
I had to back track, if someone else runs into this, you might be having the same issue
Basically this
Couldn't find WSGI module deploying Heroku
The file structure is wrong manage.py has to be at the root of the project, where Procfile and requirements.txt are, but if that's not possible to change then you can change the proc file
old procfile
web: gunicorn GroomingService.GroomingService.wsgi
new procfile
web: gunicorn --pythonpath GroomingService GroomingService.wsgi
Check your settings.py file, you might have not registered that app in your INSTALLED_APPS section.
Related
I am getting an error while deploying app on heroku
Application error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command
heroku logs --tail
Everything is working perfectly fine on heroku local
here are some of settings that I did
ALLOWED_HOSTS = ['0.0.0.0']
and here is Procfile
web: python manage.py runserver 0.0.0.0:$PORT
Here are my heroku logs
2022-07-10T16:25:15.788202+00:00 app[web.1]: The above exception was the direct cause of the following exception:
2022-07-10T16:25:15.788202+00:00 app[web.1]:
2022-07-10T16:25:15.788210+00:00 app[web.1]: Traceback (most recent call last):
2022-07-10T16:25:15.788218+00:00 app[web.1]: File "/app/manage.py", line 22, in <module>
2022-07-10T16:25:15.788278+00:00 app[web.1]: main()
2022-07-10T16:25:15.788285+00:00 app[web.1]: File "/app/manage.py", line 18, in main
2022-07-10T16:25:15.788341+00:00 app[web.1]: execute_from_command_line(sys.argv)
2022-07-10T16:25:15.788349+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
2022-07-10T16:25:15.788475+00:00 app[web.1]: utility.execute()
2022-07-10T16:25:15.788483+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/__init__.py", line 440, in execute
2022-07-10T16:25:15.788599+00:00 app[web.1]: self.fetch_command(subcommand).run_from_argv(self.argv)
2022-07-10T16:25:15.788606+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/base.py", line 414, in run_from_argv
2022-07-10T16:25:15.788717+00:00 app[web.1]: self.execute(*args, **cmd_options)
2022-07-10T16:25:15.788725+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 74, in execute
2022-07-10T16:25:15.788789+00:00 app[web.1]: super().execute(*args, **options)
2022-07-10T16:25:15.788797+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/base.py", line 460, in execute
2022-07-10T16:25:15.788909+00:00 app[web.1]: output = self.handle(*args, **options)
2022-07-10T16:25:15.788916+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 81, in handle
2022-07-10T16:25:15.788980+00:00 app[web.1]: if not settings.DEBUG and not settings.ALLOWED_HOSTS:
2022-07-10T16:25:15.788987+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/conf/__init__.py", line 87, in __getattr__
2022-07-10T16:25:15.789055+00:00 app[web.1]: self._setup(name)
2022-07-10T16:25:15.789062+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/conf/__init__.py", line 74, in _setup
2022-07-10T16:25:15.789135+00:00 app[web.1]: self._wrapped = Settings(settings_module)
2022-07-10T16:25:15.789142+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/conf/__init__.py", line 183, in __init__
2022-07-10T16:25:15.789219+00:00 app[web.1]: mod = importlib.import_module(self.SETTINGS_MODULE)
2022-07-10T16:25:15.789226+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/importlib/__init__.py", line 126, in import_module
2022-07-10T16:25:15.789298+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2022-07-10T16:25:15.789305+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
2022-07-10T16:25:15.789371+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
2022-07-10T16:25:15.789411+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
2022-07-10T16:25:15.789450+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
2022-07-10T16:25:15.789489+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 883, in exec_module
2022-07-10T16:25:15.789535+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
2022-07-10T16:25:15.789574+00:00 app[web.1]: File "/app/authentication/settings.py", line 98, in <module>
2022-07-10T16:25:15.789645+00:00 app[web.1]: 'NAME': env('DATABASE_NAME'),
2022-07-10T16:25:15.789652+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/environ/environ.py", line 197, in __call__
2022-07-10T16:25:15.789736+00:00 app[web.1]: return self.get_value(
2022-07-10T16:25:15.789743+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/environ/environ.py", line 407, in get_value
2022-07-10T16:25:15.789852+00:00 app[web.1]: raise ImproperlyConfigured(error_msg) from exc
2022-07-10T16:25:15.789898+00:00 app[web.1]: django.core.exceptions.ImproperlyConfigured: Set the DATABASE_NAME environment variable
2022-07-10T16:25:15.946054+00:00 heroku[web.1]: Process exited with status 1
2022-07-10T16:25:16.065755+00:00 heroku[web.1]: State changed from starting to crashed
2022-07-10T16:25:16.070616+00:00 heroku[web.1]: State changed from crashed to starting
2022-07-10T16:25:20.000000+00:00 app[api]: Build succeeded
2022-07-10T16:25:20.067039+00:00 heroku[web.1]: Starting process with command `python manage.py runserver 0.0.0.0:37161`
2022-07-10T16:25:21.237371+00:00 app[web.1]: Traceback (most recent call last):
2022-07-10T16:25:21.237385+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/environ/environ.py", line 403, in get_value
2022-07-10T16:25:21.237547+00:00 app[web.1]: value = self.ENVIRON[var_name]
2022-07-10T16:25:21.237555+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/os.py", line 679, in __getitem__
2022-07-10T16:25:21.237770+00:00 app[web.1]: raise KeyError(key) from None
2022-07-10T16:25:21.237797+00:00 app[web.1]: KeyError: 'DATABASE_NAME'
2022-07-10T16:25:21.237799+00:00 app[web.1]:
2022-07-10T16:25:21.237799+00:00 app[web.1]: The above exception was the direct cause of the following exception:
2022-07-10T16:25:21.237799+00:00 app[web.1]:
2022-07-10T16:25:21.237802+00:00 app[web.1]: Traceback (most recent call last):
2022-07-10T16:25:21.237811+00:00 app[web.1]: File "/app/manage.py", line 22, in <module>
2022-07-10T16:25:21.237879+00:00 app[web.1]: main()
2022-07-10T16:25:21.237881+00:00 app[web.1]: File "/app/manage.py", line 18, in main
2022-07-10T16:25:21.237946+00:00 app[web.1]: execute_from_command_line(sys.argv)
2022-07-10T16:25:21.237953+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
2022-07-10T16:25:21.238093+00:00 app[web.1]: utility.execute()
2022-07-10T16:25:21.238101+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/__init__.py", line 440, in execute
2022-07-10T16:25:21.238231+00:00 app[web.1]: self.fetch_command(subcommand).run_from_argv(self.argv)
2022-07-10T16:25:21.238240+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/base.py", line 414, in run_from_argv
2022-07-10T16:25:21.238392+00:00 app[web.1]: self.execute(*args, **cmd_options)
2022-07-10T16:25:21.238408+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 74, in execute
2022-07-10T16:25:21.238490+00:00 app[web.1]: super().execute(*args, **options)
2022-07-10T16:25:21.238492+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/base.py", line 460, in execute
2022-07-10T16:25:21.238623+00:00 app[web.1]: output = self.handle(*args, **options)
2022-07-10T16:25:21.238631+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 81, in handle
2022-07-10T16:25:21.238705+00:00 app[web.1]: if not settings.DEBUG and not settings.ALLOWED_HOSTS:
2022-07-10T16:25:21.238713+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/conf/__init__.py", line 87, in __getattr__
2022-07-10T16:25:21.238787+00:00 app[web.1]: self._setup(name)
2022-07-10T16:25:21.238795+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/conf/__init__.py", line 74, in _setup
2022-07-10T16:25:21.238865+00:00 app[web.1]: self._wrapped = Settings(settings_module)
2022-07-10T16:25:21.238873+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/conf/__init__.py", line 183, in __init__
2022-07-10T16:25:21.238981+00:00 app[web.1]: mod = importlib.import_module(self.SETTINGS_MODULE)
2022-07-10T16:25:21.238983+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/importlib/__init__.py", line 126, in import_module
2022-07-10T16:25:21.239083+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2022-07-10T16:25:21.239094+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
2022-07-10T16:25:21.239164+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
2022-07-10T16:25:21.239210+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
2022-07-10T16:25:21.239272+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
2022-07-10T16:25:21.239314+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 883, in exec_module
2022-07-10T16:25:21.239367+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
2022-07-10T16:25:21.239438+00:00 app[web.1]: File "/app/authentication/settings.py", line 98, in <module>
2022-07-10T16:25:21.239526+00:00 app[web.1]: 'NAME': env('DATABASE_NAME'),
2022-07-10T16:25:21.239528+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/environ/environ.py", line 197, in __call__
2022-07-10T16:25:21.239624+00:00 app[web.1]: return self.get_value(
2022-07-10T16:25:21.239633+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/environ/environ.py", line 407, in get_value
2022-07-10T16:25:21.239756+00:00 app[web.1]: raise ImproperlyConfigured(error_msg) from exc
2022-07-10T16:25:21.239777+00:00 app[web.1]: django.core.exceptions.ImproperlyConfigured: Set the DATABASE_NAME environment variable
2022-07-10T16:25:21.387335+00:00 heroku[web.1]: Process exited with status 1
2022-07-10T16:25:21.433687+00:00 heroku[web.1]: State changed from starting to crashed
2022-07-10T16:25:22.244946+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=noorauth.herokuapp.com request_id=955f478f-323f-4a40-8fdc-38028f4f40b8 fwd="103.184.0.73" dyno= connect= service= status=503 bytes= protocol=https
2022-07-10T16:25:22.534127+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=noorauth.herokuapp.com request_id=7f6694f9-8224-46be-b742-c20078077222 fwd="103.184.0.73" dyno= connect= service= status=503 bytes= protocol=https
2022-07-10T16:26:01.095161+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=noorauth.herokuapp.com request_id=542f9404-c45a-4264-832f-f0e4db52408c fwd="103.184.0.73" dyno= connect= service= status=503 bytes= protocol=https
2022-07-10T16:26:01.670778+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=noorauth.herokuapp.com request_id=a2e698a4-2547-4577-bc07-9b2d22293de5 fwd="103.184.0.73" dyno= connect= service= status=503 bytes= protocol=https
2022-07-10T16:29:59.391310+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=noorauth.herokuapp.com request_id=27902494-85e4-4f36-bbaa-89ae7e2895c2 fwd="103.184.0.73" dyno= connect= service= status=503 bytes= protocol=http
2022-07-10T16:30:00.717408+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=noorauth.herokuapp.com request_id=17f3bab1-2105-4677-8b94-3c2a05456c04 fwd="103.184.0.73" dyno= connect= service= status=503 bytes= protocol=http
The errors tells about the database name and everything that I have stored in .env file, what should I do, I can;t find ay help regarding the databses when deploying the app.
Your traceback is telling you that the 'DATABASE_NAME' environment variable has not been set, you can set that within your Heroku configuration.
https://devcenter.heroku.com/articles/config-vars
Another point is that your allowed hosts only has '0.0.0.0', you will need to include your Heroku app URL in there as well, or your custom URL if you are using a DNS provider.
I'm trying to deploy a Django app to heroku. I get an error of ModuleNotFoundError: No module named 'games.wsgi' where games is my project name. My Procfile created is
web: gunicorn games.wsgi . I have installed gunicorn. My requirements.txt is
asgiref==3.3.4
Django==3.2
gunicorn==20.1.0
pytz==2021.1
sqlparse==0.4.1
and pipfile also has [packages] gunicorn = "*"
my wsgi file has os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'games.settings')
my heroku logs show
File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 551, in manage_workers
2021-06-14T10:51:35.947270+00:00 app[web.1]: self.spawn_workers()
2021-06-14T10:51:35.947294+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 623, in spawn_workers
2021-06-14T10:51:35.947812+00:00 app[web.1]: time.sleep(0.1 * random.random())
2021-06-14T10:51:35.947840+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
2021-06-14T10:51:35.948243+00:00 app[web.1]: self.reap_workers()
2021-06-14T10:51:35.948270+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2021-06-14T10:51:35.948797+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2021-06-14T10:51:35.949024+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2021-06-14T10:51:35.949049+00:00 app[web.1]:
2021-06-14T10:51:35.949050+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2021-06-14T10:51:35.949050+00:00 app[web.1]:
2021-06-14T10:51:35.949077+00:00 app[web.1]: Traceback (most recent call last):
2021-06-14T10:51:35.949147+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn", line 8, in <module>
2021-06-14T10:51:35.949409+00:00 app[web.1]: sys.exit(run())
2021-06-14T10:51:35.949438+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 67, in run
2021-06-14T10:51:35.949744+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2021-06-14T10:51:35.949767+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/base.py", line 231, in run
2021-06-14T10:51:35.950117+00:00 app[web.1]: super().run()
2021-06-14T10:51:35.950143+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/base.py", line 72, in run
2021-06-14T10:51:35.950381+00:00 app[web.1]: Arbiter(self).run()
2021-06-14T10:51:35.950404+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 229, in run
2021-06-14T10:51:35.950785+00:00 app[web.1]: self.halt(reason=inst.reason, exit_status=inst.exit_status)
2021-06-14T10:51:35.950813+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 342, in halt
2021-06-14T10:51:35.951272+00:00 app[web.1]: self.stop()
2021-06-14T10:51:35.951300+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 393, in stop
2021-06-14T10:51:35.951781+00:00 app[web.1]: time.sleep(0.1)
2021-06-14T10:51:35.951810+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
2021-06-14T10:51:35.952157+00:00 app[web.1]: self.reap_workers()
2021-06-14T10:51:35.952180+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2021-06-14T10:51:35.952629+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2021-06-14T10:51:35.952784+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2021-06-14T10:51:36.054399+00:00 heroku[web.1]: Process exited with status 1
2021-06-14T10:51:36.153878+00:00 heroku[web.1]: State changed from starting to crashed
2021-06-14T10:55:27.000000+00:00 app[api]: Build started by user myname.com
2021-06-14T10:55:50.869971+00:00 app[api]: Deploy dbdd2c5e by user myname.com
2021-06-14T10:55:50.869971+00:00 app[api]: Release v17 created by user myname#gmail.com
2021-06-14T10:55:51.193981+00:00 heroku[web.1]: State changed from crashed to starting
2021-06-14T10:55:56.765467+00:00 heroku[web.1]: Starting process with command `gunicorn games.wsgi`
2021-06-14T10:55:59.711217+00:00 app[web.1]: [2021-06-14 10:55:59 +0000] [4] [INFO] Starting gunicorn 20.1.0
2021-06-14T10:55:59.711739+00:00 app[web.1]: [2021-06-14 10:55:59 +0000] [4] [INFO] Listening at: http://0.0.0.0:14430 (4)
2021-06-14T10:55:59.711817+00:00 app[web.1]: [2021-06-14 10:55:59 +0000] [4] [INFO] Using worker: sync
2021-06-14T10:55:59.715825+00:00 app[web.1]: [2021-06-14 10:55:59 +0000] [8] [INFO] Booting worker with pid: 8
2021-06-14T10:55:59.722359+00:00 app[web.1]: [2021-06-14 10:55:59 +0000] [8] [ERROR] Exception in worker process
2021-06-14T10:55:59.722360+00:00 app[web.1]: Traceback (most recent call last):
2021-06-14T10:55:59.722361+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
2021-06-14T10:55:59.722361+00:00 app[web.1]: worker.init_process()
2021-06-14T10:55:59.722361+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 134, in init_process
2021-06-14T10:55:59.722362+00:00 app[web.1]: self.load_wsgi()
2021-06-14T10:55:59.722362+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
2021-06-14T10:55:59.722362+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2021-06-14T10:55:59.722363+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
2021-06-14T10:55:59.722363+00:00 app[web.1]: self.callable = self.load()
2021-06-14T10:55:59.722363+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
2021-06-14T10:55:59.722363+00:00 app[web.1]: return self.load_wsgiapp()
2021-06-14T10:55:59.722363+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2021-06-14T10:55:59.722364+00:00 app[web.1]: return util.import_app(self.app_uri)
2021-06-14T10:55:59.722364+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/util.py", line 359, in import_app
2021-06-14T10:55:59.722364+00:00 app[web.1]: mod = importlib.import_module(module)
2021-06-14T10:55:59.722364+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
2021-06-14T10:55:59.722365+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2021-06-14T10:55:59.722365+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
2021-06-14T10:55:59.722365+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
2021-06-14T10:55:59.722365+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
2021-06-14T10:55:59.722366+00:00 app[web.1]: ModuleNotFoundError: No module named 'games.wsgi'
2021-06-14T10:55:59.722473+00:00 app[web.1]: [2021-06-14 10:55:59 +0000] [8] [INFO] Worker exiting (pid: 8)
2021-06-14T10:55:59.738771+00:00 app[web.1]: [2021-06-14 10:55:59 +0000] [9] [INFO] Booting worker with pid: 9
2021-06-14T10:55:59.746563+00:00 app[web.1]: [2021-06-14 10:55:59 +0000] [9] [ERROR] Exception in worker process
2021-06-14T10:55:59.746564+00:00 app[web.1]: Traceback (most recent call last):
2021-06-14T10:55:59.746565+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
2021-06-14T10:55:59.746565+00:00 app[web.1]: worker.init_process()
2021-06-14T10:55:59.746565+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 134, in init_process
2021-06-14T10:55:59.746566+00:00 app[web.1]: self.load_wsgi()
2021-06-14T10:55:59.746566+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
2021-06-14T10:55:59.746566+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2021-06-14T10:55:59.746567+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
2021-06-14T10:55:59.746567+00:00 app[web.1]: self.callable = self.load()
2021-06-14T10:55:59.746567+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
2021-06-14T10:55:59.746568+00:00 app[web.1]: return self.load_wsgiapp()
2021-06-14T10:55:59.746568+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2021-06-14T10:55:59.746568+00:00 app[web.1]: return util.import_app(self.app_uri)
2021-06-14T10:55:59.746568+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/util.py", line 359, in import_app
2021-06-14T10:55:59.746568+00:00 app[web.1]: mod = importlib.import_module(module)
2021-06-14T10:55:59.746569+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
2021-06-14T10:55:59.746569+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2021-06-14T10:55:59.746569+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
2021-06-14T10:55:59.746569+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
2021-06-14T10:55:59.746570+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
2021-06-14T10:55:59.746570+00:00 app[web.1]: ModuleNotFoundError: No module named 'games.wsgi'
2021-06-14T10:55:59.746797+00:00 app[web.1]: [2021-06-14 10:55:59 +0000] [9] [INFO] Worker exiting (pid: 9)
2021-06-14T10:55:59.769510+00:00 app[web.1]: [2021-06-14 10:55:59 +0000] [4] [WARNING] Worker with pid 9 was terminated due to signal 15
2021-06-14T10:55:59.868197+00:00 app[web.1]: [2021-06-14 10:55:59 +0000] [4] [INFO] Shutting down: Master
2021-06-14T10:55:59.868318+00:00 app[web.1]: [2021-06-14 10:55:59 +0000] [4] [INFO] Reason: Worker failed to boot.
2021-06-14T10:55:59.935108+00:00 heroku[web.1]: Process exited with status 3
2021-06-14T10:56:00.034150+00:00 heroku[web.1]: State changed from starting to crashed
2021-06-14T10:56:01.000000+00:00 app[api]: Build succeeded
2021-06-14T10:56:14.181661+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=gameportaladitya.herokuapp.com request_id=3c6f34d2-b6cd-4d58-a6b2-985e495daf0f fwd="122.177.148.42" dyno= connect= service= status=503 bytes= protocol=https
2021-06-14T10:56:15.394506+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=gameportaladitya.herokuapp.com request_id=5693205c-1af0-4846-be22-cf96d5306131 fwd="122.177.148.42" dyno= connect= service= status=503 bytes= protocol=https
2021-06-14T10:56:34.499111+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=gameportaladitya.herokuapp.com request_id=b3f8aa4e-b89f-4112-8330-fe52851ff034 fwd="122.177.148.42" dyno= connect= service= status=503 bytes= protocol=https
2021-06-14T10:56:36.300878+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=gameportaladitya.herokuapp.com request_id=5b31ffe7-48a2-4751-a388-a526447b1179 fwd="122.177.148.42" dyno= connect= service= status=503 bytes= protocol=https
My directory structure is
D:.
│ .gitignore
│ Pipfile
│ Pipfile.lock
│ Procfile
│ requirements.txt
│
│
└───games
│ db.sqlite3
│ manage.py
│
├───games
│ asgi.py
│ settings.py
│ urls.py
│ wsgi.py
│ __init__.py
│
├───my_games
│ │ admin.py
│ │ apps.py
│ │ models.py
│ │ tests.py
│ │ views.py
│ │ __init__.py
│ │
│ └───migrations
│ 0001_initial.py
│ __init__.py
│
├───static
Can someone help I have been trying to figure out but everything seems to be correct but still I'm getting this error
Probably it's about Python path.
Had the same problem on Centos8.
Simply changed PYTHONPATH to the directory wsgi.py is in.
In case of Linux it would be export PYTHONPATH='D/games/games'.
If you use IDE, you can manage PYTHONPATH from IDE settings.
Then step one level upper to 'D/games' and then try
gunicorn games.wsgi:application.
idk how to change pythonath on Windows but seems this article is all about it:
How to add to the PYTHONPATH in Windows, so it finds my modules/packages?
Build is successdul and it is producing application error, i have set up host name and debug=False as suggested but it is still causing error in opening the browser window, i am new to heroku so please suggest what needs to be done to make it work
my settings.py
"""
Django settings for djangoTut project.
Generated by 'django-admin startproject' using Django 3.2.4.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""
from pathlib import Path
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
print(BASE_DIR)
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = mysecretkey
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['djangoblog-project.herokuapp.com']
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog.apps.BlogConfig',
'users.apps.UsersConfig',
'crispy_forms',
]
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',
]
ROOT_URLCONF = 'djangoTut.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 = 'djangoTut.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'DATABASE' : 'DjangoProject',
'NAME': 'DjangoProject',
'USER' : 'myprojectuser',
'PASSWORD' : 'Akbar#123456',
'HOST': 'localhost',
'PORT': '',
# 'default-character-se' : 'utf8',
# 'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/3.2/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.2/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.2/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
STATICFILES_DIRS = [
]
CRISPY_TEMPLATE_PACK = 'bootstrap4'
# STATIC_ROOT = os.path.join(BASE_DIR, 'assets')
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
LOGIN_REDIRECT_URL = 'blogHome'
LOGIN_URL = 'login'
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
requirements.txt for the current django project
requirements.txt
boto3==1.9.96
botocore==1.12.96
certifi==2018.10.15
chardet==3.0.4
dj-database-url==0.5.0
Django==2.1
django-crispy-forms==1.7.2
django-heroku==0.3.1
django-storages==1.7.1
docutils==0.14
gunicorn==19.9.0
idna==2.7
jmespath==0.9.3
Pillow==5.2.0
python-dateutil==2.8.0
pytz==2018.5
requests==2.19.1
s3transfer==0.2.0
six==1.12.0
urllib3==1.23
whitenoise==4.1.2
heroku logs
› Warning: heroku update available from 7.52.0 to 7.54.0.
2021-06-12T09:49:28.101517+00:00 app[web.1]: Arbiter(self).run()
2021-06-12T09:49:28.101521+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 232, in run
2021-06-12T09:49:28.101745+00:00 app[web.1]: self.halt(reason=inst.reason, exit_status=inst.exit_status)
2021-06-12T09:49:28.101747+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 345, in halt
2021-06-12T09:49:28.101999+00:00 app[web.1]: self.stop()
2021-06-12T09:49:28.102004+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 393, in stop
2021-06-12T09:49:28.102241+00:00 app[web.1]: time.sleep(0.1)
2021-06-12T09:49:28.102246+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 245, in handle_chld
2021-06-12T09:49:28.102398+00:00 app[web.1]: self.reap_workers()
2021-06-12T09:49:28.102404+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2021-06-12T09:49:28.102716+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2021-06-12T09:49:28.102754+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2021-06-12T09:49:28.205668+00:00 heroku[web.1]: Process exited with status 1
2021-06-12T09:49:28.284579+00:00 heroku[web.1]: State changed from starting to crashed
2021-06-12T09:49:34.912538+00:00 app[api]: Release v9 created by user dhruv.singhal2612#gmail.com
2021-06-12T09:49:34.912538+00:00 app[api]: Set DEBUG_VALUE config vars by user dhruv.singhal2612#gmail.com
2021-06-12T09:49:35.143657+00:00 heroku[web.1]: State changed from crashed to starting
2021-06-12T09:49:41.619208+00:00 heroku[web.1]: Starting process with command `gunicorn django_project.wsgi`
2021-06-12T09:49:45.299640+00:00 app[web.1]: [2021-06-12 09:49:45 +0000] [4] [INFO] Starting gunicorn 19.9.0
2021-06-12T09:49:45.300103+00:00 app[web.1]: [2021-06-12 09:49:45 +0000] [4] [INFO] Listening at: http://0.0.0.0:16332 (4)
2021-06-12T09:49:45.300346+00:00 app[web.1]: [2021-06-12 09:49:45 +0000] [4] [INFO] Using worker: sync
2021-06-12T09:49:45.302082+00:00 app[web.1]: /app/.heroku/python/lib/python3.9/os.py:1023: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
2021-06-12T09:49:45.302083+00:00 app[web.1]: return io.open(fd, *args, **kwargs)
2021-06-12T09:49:45.306106+00:00 app[web.1]: [2021-06-12 09:49:45 +0000] [7] [INFO] Booting worker with pid: 7
2021-06-12T09:49:45.312314+00:00 app[web.1]: [2021-06-12 09:49:45 +0000] [7] [ERROR] Exception in worker process
2021-06-12T09:49:45.312315+00:00 app[web.1]: Traceback (most recent call last):
2021-06-12T09:49:45.312326+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2021-06-12T09:49:45.312326+00:00 app[web.1]: worker.init_process()
2021-06-12T09:49:45.312327+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 129, in init_process
2021-06-12T09:49:45.312328+00:00 app[web.1]: self.load_wsgi()
2021-06-12T09:49:45.312328+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2021-06-12T09:49:45.312328+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2021-06-12T09:49:45.312329+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi
2021-06-12T09:49:45.312329+00:00 app[web.1]: self.callable = self.load()
2021-06-12T09:49:45.312329+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2021-06-12T09:49:45.312330+00:00 app[web.1]: return self.load_wsgiapp()
2021-06-12T09:49:45.312330+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2021-06-12T09:49:45.312331+00:00 app[web.1]: return util.import_app(self.app_uri)
2021-06-12T09:49:45.312331+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/util.py", line 350, in import_app
2021-06-12T09:49:45.312331+00:00 app[web.1]: __import__(module)
2021-06-12T09:49:45.312332+00:00 app[web.1]: ModuleNotFoundError: No module named 'django_project'
2021-06-12T09:49:45.312475+00:00 app[web.1]: [2021-06-12 09:49:45 +0000] [7] [INFO] Worker exiting (pid: 7)
2021-06-12T09:49:45.342275+00:00 app[web.1]: [2021-06-12 09:49:45 +0000] [8] [INFO] Booting worker with pid: 8
2021-06-12T09:49:45.354724+00:00 app[web.1]: [2021-06-12 09:49:45 +0000] [8] [ERROR] Exception in worker process
2021-06-12T09:49:45.354725+00:00 app[web.1]: Traceback (most recent call last):
2021-06-12T09:49:45.354726+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2021-06-12T09:49:45.354726+00:00 app[web.1]: worker.init_process()
2021-06-12T09:49:45.354727+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 129, in init_process
2021-06-12T09:49:45.354727+00:00 app[web.1]: self.load_wsgi()
2021-06-12T09:49:45.354728+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2021-06-12T09:49:45.354728+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2021-06-12T09:49:45.354728+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi
2021-06-12T09:49:45.354729+00:00 app[web.1]: self.callable = self.load()
2021-06-12T09:49:45.354729+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2021-06-12T09:49:45.354730+00:00 app[web.1]: return self.load_wsgiapp()
2021-06-12T09:49:45.354730+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2021-06-12T09:49:45.354730+00:00 app[web.1]: return util.import_app(self.app_uri)
2021-06-12T09:49:45.354731+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/util.py", line 350, in import_app
2021-06-12T09:49:45.354731+00:00 app[web.1]: __import__(module)
2021-06-12T09:49:45.354732+00:00 app[web.1]: ModuleNotFoundError: No module named 'django_project'
2021-06-12T09:49:45.354973+00:00 app[web.1]: [2021-06-12 09:49:45 +0000] [8] [INFO] Worker exiting (pid: 8)
2021-06-12T09:49:45.396511+00:00 app[web.1]: Traceback (most recent call last):
2021-06-12T09:49:45.396519+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 203, in run
2021-06-12T09:49:45.396872+00:00 app[web.1]: self.manage_workers()
2021-06-12T09:49:45.396873+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 545, in manage_workers
2021-06-12T09:49:45.397354+00:00 app[web.1]: self.spawn_workers()
2021-06-12T09:49:45.397381+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 617, in spawn_workers
2021-06-12T09:49:45.397935+00:00 app[web.1]: time.sleep(0.1 * random.random())
2021-06-12T09:49:45.397962+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 245, in handle_chld
2021-06-12T09:49:45.398390+00:00 app[web.1]: self.reap_workers()
2021-06-12T09:49:45.398463+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2021-06-12T09:49:45.398958+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2021-06-12T09:49:45.399217+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2021-06-12T09:49:45.399240+00:00 app[web.1]:
2021-06-12T09:49:45.399240+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2021-06-12T09:49:45.399241+00:00 app[web.1]:
2021-06-12T09:49:45.399265+00:00 app[web.1]: Traceback (most recent call last):
2021-06-12T09:49:45.399340+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn", line 8, in <module>
2021-06-12T09:49:45.399650+00:00 app[web.1]: sys.exit(run())
2021-06-12T09:49:45.399677+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 61, in run
2021-06-12T09:49:45.400017+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2021-06-12T09:49:45.400048+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 223, in run
2021-06-12T09:49:45.400760+00:00 app[web.1]: super(Application, self).run()
2021-06-12T09:49:45.400788+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 72, in run
2021-06-12T09:49:45.401131+00:00 app[web.1]: Arbiter(self).run()
2021-06-12T09:49:45.401164+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 232, in run
2021-06-12T09:49:45.401541+00:00 app[web.1]: self.halt(reason=inst.reason, exit_status=inst.exit_status)
2021-06-12T09:49:45.401569+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 345, in halt
2021-06-12T09:49:45.402002+00:00 app[web.1]: self.stop()
2021-06-12T09:49:45.402029+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 393, in stop
2021-06-12T09:49:45.402490+00:00 app[web.1]: time.sleep(0.1)
2021-06-12T09:49:45.402519+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 245, in handle_chld
2021-06-12T09:49:45.403126+00:00 app[web.1]: self.reap_workers()
2021-06-12T09:49:45.403154+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2021-06-12T09:49:45.403652+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2021-06-12T09:49:45.403847+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2021-06-12T09:49:45.504630+00:00 heroku[web.1]: Process exited with status 1
2021-06-12T09:49:45.573000+00:00 heroku[web.1]: State changed from starting to crashed
2021-06-12T09:50:28.064356+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=djangoblog-project.herokuapp.com request_id=55fab425-ef64-485a-892c-cbf2120401ce fwd="223.184.234.62" dyno= connect= service= status=503 bytes= protocol=https
2021-06-12T09:50:28.695891+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=djangoblog-project.herokuapp.com request_id=2c5d885e-39a1-4683-aa17-28efabadd898 fwd="223.184.234.62" dyno= connect= service= status=503 bytes= protocol=https
If you are using django-heroku package than you have to add this in your settings.py
Add the following import statement to the top of settings.py:
import django_heroku
and Then add the following to the bottom of settings.py:
# Activate Django-Heroku.
django_heroku.settings(locals())
check official doc. https://devcenter.heroku.com/articles/django-app-configuration#settings-py-changes
Did you create the Procfile file in the project folder?
If you are using Windows PS, you can type in terminal:
echo web: gunicorn <<YOUR_PROJECT>>.wsgi --log-file - > Procfile
Another possible solution is to use Postgres instead of MySQL:
In settings.py:
DATABASES = {
'default': dj_database_url.config()
}
In requirements.txt:
psycopg2-binary==2.8.6
I am deploying an e-commerce project to Heroku and seem to be running into constant issues and errors.
My latest error surrounds the below traceback:
2019-11-11T13:35:34.080363+00:00 heroku[web.1]: State changed from crashed to starting
2019-11-11T13:35:40.020789+00:00 heroku[web.1]: Starting process with command `gunicorn fancyfetish.wsgi:application --preload --workers 1`
2019-11-11T13:35:42.589255+00:00 heroku[web.1]: State changed from starting to crashed
2019-11-11T13:35:42.460008+00:00 app[web.1]: Traceback (most recent call last):
2019-11-11T13:35:42.460049+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn", line 11, in <module>
2019-11-11T13:35:42.460136+00:00 app[web.1]: sys.exit(run())
2019-11-11T13:35:42.460148+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 58, in run
2019-11-11T13:35:42.460262+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2019-11-11T13:35:42.460273+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 219, in run
2019-11-11T13:35:42.460434+00:00 app[web.1]: super().run()
2019-11-11T13:35:42.460438+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 72, in run
2019-11-11T13:35:42.460565+00:00 app[web.1]: Arbiter(self).run()
2019-11-11T13:35:42.460571+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 58, in __init__
2019-11-11T13:35:42.460689+00:00 app[web.1]: self.setup(app)
2019-11-11T13:35:42.460692+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 118, in setup
2019-11-11T13:35:42.460823+00:00 app[web.1]: self.app.wsgi()
2019-11-11T13:35:42.460827+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2019-11-11T13:35:42.460978+00:00 app[web.1]: self.callable = self.load()
2019-11-11T13:35:42.460981+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
2019-11-11T13:35:42.461083+00:00 app[web.1]: return self.load_wsgiapp()
2019-11-11T13:35:42.461087+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
2019-11-11T13:35:42.461204+00:00 app[web.1]: return util.import_app(self.app_uri)
2019-11-11T13:35:42.461207+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 331, in import_app
2019-11-11T13:35:42.461388+00:00 app[web.1]: mod = importlib.import_module(module)
2019-11-11T13:35:42.461392+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
2019-11-11T13:35:42.461529+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2019-11-11T13:35:42.461542+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 994, in _gcd_import
2019-11-11T13:35:42.461664+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 971, in _find_and_load
2019-11-11T13:35:42.461737+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
2019-11-11T13:35:42.461813+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
2019-11-11T13:35:42.461888+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 678, in exec_module
2019-11-11T13:35:42.461983+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2019-11-11T13:35:42.462061+00:00 app[web.1]: File "/app/fancyfetish/wsgi.py", line 17, in <module>
2019-11-11T13:35:42.462171+00:00 app[web.1]: application = get_wsgi_application()
2019-11-11T13:35:42.462176+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2019-11-11T13:35:42.462279+00:00 app[web.1]: django.setup(set_prefix=False)
2019-11-11T13:35:42.462298+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 19, in setup
2019-11-11T13:35:42.462381+00:00 app[web.1]: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2019-11-11T13:35:42.462385+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 79, in __getattr__
2019-11-11T13:35:42.462516+00:00 app[web.1]: self._setup(name)
2019-11-11T13:35:42.462519+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 66, in _setup
2019-11-11T13:35:42.462637+00:00 app[web.1]: self._wrapped = Settings(settings_module)
2019-11-11T13:35:42.462639+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 176, in __init__
2019-11-11T13:35:42.462783+00:00 app[web.1]: raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
2019-11-11T13:35:42.462808+00:00 app[web.1]: django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
2019-11-11T13:35:42.575764+00:00 heroku[web.1]: Process exited with status 1
2019-11-11T13:35:47.000000+00:00 app[api]: Build succeeded
2019-11-11T13:36:25.358883+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fancyfetish.herokuapp.com request_id=4f0e5e77-53c9-443a-8647-c5b88a01ae17 fwd="81.100.164.113" dyno= connect= service= status=503 bytes= protocol=https
2019-11-11T13:36:25.563374+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=fancyfetish.herokuapp.com request_id=3828cca1-593c-4785-9c82-6b614c233dea fwd="81.100.164.113" dyno= connect= service= status=503 bytes= protocol=https
I have got three settings files under the directory settings, outlined below:
|____settings
| |______init__.py
| |____development.py
| |______pycache__
| | |____production.cpython-37.pyc
| | |____base.cpython-37.pyc
| | |____development.cpython-37.pyc
| | |______init__.cpython-37.pyc
| |____base.py
| |____production.py
|______init__.py
|______pycache__
| |____settings.cpython-37.pyc
| |____wsgi.cpython-37.pyc
| |____urls.cpython-37.pyc
| |______init__.cpython-37.pyc
|____urls.py
|____wsgi.py
All three of my settings files (base.py, development.py and production.py) have a SECRET_KEY defined so I am not sure why this error keeps appearing.
The SECRET_KEY is randomly generated. Is this to do with gunicorn?
My wsgi file looks like this:
import os
from django.core.wsgi import get_wsgi_application
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'fancyfetish.settings')
application = get_wsgi_application()
(I am unsure if I even need to import from django.core.wsgi but this seemed to be someone elses solution, it didn't work for me)
My Procfile looks like this:
web: gunicorn fancyfetish.wsgi:application --preload --workers 1
My requirements.txt file looks like this:
beautifulsoup4==4.8.1
Django==2.2.6
django-appconf==1.0.3
django-bootstrap4==1.0.1
django-compressor==2.3
django-libsass==0.7
django-sass-processor==0.7.4
gunicorn==20.0.0
libsass==0.19.3
mysql-connector-python==8.0.18
Pillow==6.2.1
protobuf==3.10.0
pytz==2019.3
rcssmin==1.0.6
rjsmin==1.1.0
six==1.12.0
soupsieve==1.9.5
sqlparse==0.3.0
Is anyone able to see whay I am doing so wrong? Is it a compatibility issue between versions?
Try changing this line in your wsgi file:
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'fancyfetish.settings')
for this:
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'fancyfetish.settings.development') # or .production
I have been trying to deploy an app to Heroku (no frills, just a simple page) but have not managed to do so. This is my log file -
2014-08-03T21:02:53.886884+00:00 heroku[web.1]: Starting process with command `gunicorn TestApp.wsgi`
2014-08-03T21:02:57.218280+00:00 heroku[web.1]: Process exited with status 3
2014-08-03T21:03:00.994045+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/"
host=fierce-oasis-7567.herokuapp.com request_id=f53c4902-5a52-4591-a099-ef006a4658d0 fwd="202.78.172.162"
dyno= connect= service= status=503 bytes=
2014-08-03T21:03:02.570801+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET
path="/favicon.ico" host=fierce-oasis-7567.herokuapp.com request_id=22872708-cf36-47b1- a5e6-552b7a1a8668
fwd="202.78.172.162" dyno= connect= service= status=503 bytes=
2014-08-03T21:14:34+00:00 heroku[slug-compiler]: Slug compilation started
2014-08-03T21:15:02+00:00 heroku[slug-compiler]: Slug compilation finished
2014-08-03T21:15:02.272206+00:00 heroku[web.1]: State changed from crashed to starting
2014-08-03T21:15:02.150270+00:00 heroku[api]: Deploy 9b69a49 by utsav.tiwary2011#gmail.com
2014-08-03T21:15:02.150376+00:00 heroku[api]: Release v8 created by utsav.tiwary2011#gmail.com
2014-08-03T21:15:06.900391+00:00 app[web.1]: Traceback (most recent call last):
2014-08-03T21:15:06.900398+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2014-08-03T21:15:06.885690+00:00 app[web.1]: 2014-08-03 21:15:06 [2] [INFO] Starting gunicorn 18.0
2014-08-03T21:15:06.900396+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/workers/base.py", line 106, in init_process
2014-08-03T21:15:06.900402+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/app/wsgiapp.py", line 62, in load
2014-08-03T21:15:06.900399+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/app/base.py", line 114, in wsgi
2014-08-03T21:15:06.900408+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/util.py", line 354, in import_app
2014-08-03T21:15:06.900404+00:00 app[web.1]: return self.load_wsgiapp()
2014-08-03T21:15:06.900411+00:00 app[web.1]: ImportError: No module named TestApp.wsgi
2014-08-03T21:15:06.900410+00:00 app[web.1]: __import__(module)
2014-08-03T21:15:06.900413+00:00 app[web.1]: Traceback (most recent call last):
2014-08-03T21:15:06.900419+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2014-08-03T21:15:06.900388+00:00 app[web.1]: 2014-08-03 21:15:06 [7] [ERROR] Exception in worker process:
2014-08-03T21:15:06.900406+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
2014-08-03T21:15:06.900417+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/workers/base.py", line 106, in init_process
2014-08-03T21:15:06.886483+00:00 app[web.1]: 2014-08-03 21:15:06 [2] [INFO] Listening at:
http://0.0.0.0:3589 (2)
2014-08-03T21:15:06.900427+00:00 app[web.1]: return util.import_app(self.app_uri)
2014-08-03T21:15:06.900414+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/arbit
er.py", line 495, in spawn_worker
2014-08-03T21:15:06.900416+00:00 app[web.1]: worker.init_process()
2014-08-03T21:15:06.900393+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/arbiter.py", line 495, in spawn_worker
2014-08-03T21:15:06.900394+00:00 app[web.1]: worker.init_process()
2014-08-03T21:15:06.900420+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/app/base.py", line 114, in wsgi
2014-08-03T21:15:06.896296+00:00 app[web.1]: 2014-08-03 21:15:06 [7] [INFO] Booting worker with pid: 7
2014-08-03T21:15:06.900421+00:00 app[web.1]: self.callable = self.load()
2014-08-03T21:15:06.900428+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/util.py", line 354, in import_app
2014-08-03T21:15:06.900401+00:00 app[web.1]: self.callable = self.load()
2014-08-03T21:15:06.900407+00:00 app[web.1]: return util.import_app(self.app_uri)
2014-08-03T21:15:06.900423+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/app/wsgiapp.py", line 62, in load
2014-08-03T21:15:06.900429+00:00 app[web.1]: __import__(module)
2014-08-03T21:15:06.900431+00:00 app[web.1]: ImportError: No module named TestApp.wsgi
2014-08-03T21:15:07.024019+00:00 app[web.1]: 2014-08-03 21:15:07 [2] [INFO] Shutting down: Master
2014-08-03T21:15:06.900424+00:00 app[web.1]: return self.load_wsgiapp()
2014-08-03T21:15:07.024128+00:00 app[web.1]: 2014-08-03 21:15:07 [2] [INFO] Reason: Worker failed to boot.
2014-08-03T21:15:06.886586+00:00 app[web.1]: 2014-08-03 21:15:06 [2] [INFO] Using worker: sync
2014-08-03T21:15:06.900425+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
2014-08-03T21:15:06.900514+00:00 app[web.1]: 2014-08-03 21:15:06 [7] [INFO] Worker exiting (pid: 7)
2014-08-03T21:15:05.633019+00:00 heroku[web.1]: Starting process with command `gunicorn TestApp.wsgi`
2014-08-03T21:15:08.072497+00:00 heroku[web.1]: Process exited with status 3
2014-08-03T21:15:08.083536+00:00 heroku[web.1]: State changed from starting to crashed
2014-08-03T21:15:08.084259+00:00 heroku[web.1]: State changed from crashed to starting
2014-08-03T21:15:11.225689+00:00 heroku[web.1]: Starting process with command `gunicorn TestApp.wsgi`
2014-08-03T21:15:12.151723+00:00 app[web.1]: 2014-08-03 21:15:12 [2] [INFO] Starting gunicorn 18.0
2014-08-03T21:15:12.166252+00:00 app[web.1]: worker.init_process()
2014-08-03T21:15:12.166257+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/app/base.py", line 114, in wsgi
2014-08-03T21:15:12.166251+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/arbiter.py", line 495, in spawn_worker
2014-08-03T21:15:12.166249+00:00 app[web.1]: Traceback (most recent call last):
2014-08-03T21:15:12.166260+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/app/wsgiapp.py", line 62, in load
2014-08-03T21:15:12.166246+00:00 app[web.1]: 2014-08-03 21:15:12 [7] [ERROR] Exception in worker process:
2014-08-03T21:15:12.166256+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2014-08-03T21:15:12.166265+00:00 app[web.1]: return util.import_app(self.app_uri)
2014-08-03T21:15:12.166259+00:00 app[web.1]: self.callable = self.load()
2014-08-03T21:15:12.166262+00:00 app[web.1]: return self.load_wsgiapp()
2014-08-03T21:15:12.166254+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/workers/base.py", line 106, in init_process
2014-08-03T21:15:12.166263+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
2014-08-03T21:15:12.166273+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/arbiter.py", line 495, i
n spawn_worker
2014-08-03T21:15:12.166271+00:00 app[web.1]: Traceback (most recent call last):
2014-08-03T21:15:12.166275+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/workers/base.py", line 106, in init_process
2014-08-03T21:15:12.166287+00:00 app[web.1]: __import__(module)
2014-08-03T21:15:12.166266+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/util.py", line 354, in import_app
2014-08-03T21:15:12.166281+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/app/wsgiapp.py", line 62, in load
2014-08-03T21:15:12.166268+00:00 app[web.1]: __import__(module)
2014-08-03T21:15:12.166289+00:00 app[web.1]: ImportError: No module named TestApp.wsgi
2014-08-03T21:15:12.166274+00:00 app[web.1]: worker.init_process()
2014-08-03T21:15:12.166278+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/app/base.py", line 114, in wsgi
2014-08-03T21:15:12.166269+00:00 app[web.1]: ImportError: No module named TestApp.wsgi
2014-08-03T21:15:12.166285+00:00 app[web.1]: return util.import_app(self.app_uri)
2014-08-03T21:15:12.166283+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
2014-08-03T21:15:12.152842+00:00 app[web.1]: 2014-08-03 21:15:12 [2] [INFO] Using worker: sync
2014-08-03T21:15:12.166277+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2014-08-03T21:15:12.166282+00:00 app[web.1]: return self.load_wsgiapp()
2014-08-03T21:15:12.166279+00:00 app[web.1]: self.callable = self.load()
2014-08-03T21:15:12.152750+00:00 app[web.1]: 2014-08-03 21:15:12 [2] [INFO] Listening at:
http://0.0.0.0:28415 (2)
2014-08-03T21:15:12.287650+00:00 app[web.1]: 2014-08-03 21:15:12 [2] [INFO] Reason: Worker failed to boot.
2014-08-03T21:15:12.287529+00:00 app[web.1]: 2014-08-03 21:15:12 [2] [INFO] Shutting down: Master
2014-08-03T21:15:12.166286+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/util.py", line 354, in import_app
2014-08-03T21:15:12.166363+00:00 app[web.1]: 2014-08-03 21:15:12 [7] [INFO] Worker exiting (pid: 7)
2014-08-03T21:15:12.162414+00:00 app[web.1]: 2014-08-03 21:15:12 [7] [INFO] Booting worker with pid: 7
2014-08-03T21:15:15.136154+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/"
host=fierce-oasis-7567.herokuapp.com request_id=86c520f6-3c60-4817-a006-7d5111a22a3c fwd="54.83.118.7" dyno=
connect= service= status=503 bytes=
2014-08-03T21:15:13.398231+00:00 heroku[web.1]: State changed from starting to crashed
2014-08-03T21:15:13.379837+00:00 heroku[web.1]: Process exited with status 3
And this is my Procfile :
web: gunicorn TestApp.wsgi
This is my requirements.txt
Django<=1.3.1
dj-database-url==0.3.0
psycopg2==2.4.5
gunicorn==18.0
wsgiref==0.1.2
dj-static==0.0.5
static==0.4
This is my settings file:
# Django settings for TestApp project.
import os
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
ALLOWED_HOSTS = ['*']
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = 'staticfiles'
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(PROJECT_PATH, 'static'),
)
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email#example.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Chicago'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True
# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = ''
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
# Additional locations of static files
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'n(bd1f1c%e8=_xad02x5qtfn%wgwpi492e$8_erx+d)!tpeoim'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'TestApp.urls'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'TestApp.wsgi.application'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'gunicorn',
# Uncomment the next line to enable the admin:
# 'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
import dj_database_url
DATABASES['default'] = dj_database_url.config()
Procfile : web: sh -c "cd TestApp && gunicorn TestApp.wsgi"
Basically, my error is that it is not able to locate TestApp.wsgi and hence crashes every time. I followed the following steps while deploying -
git add -A.
git commit -m"commit"
git push heroku master
git ps
Can anyone please help me figure out what is wrong ? Thanks in advance ! (Please let me know if any other file/detail
is needed)