Gunicorn Not Finding core.wsgi in Django Project

MANNA_RAMIRO/
├── core/
│ ├── core/
│ │ ├── init.py
│ │ ├── settings.py
│ │ ├── urls.py
│ │ ├── wsgi.py
│ ├── manage.py
│ ├── Authentication/
│ │ ├── init.py
│ │ ├── models.py
│ │ ├── views.py
│ ├── Cadastro/
│ │ ├── init.py
│ │ ├── models.py
│ │ ├── views.py
├── requirements.txt
└── build.sh

My wsgi.py file is located in MANNA_RAMIRO/core/core/wsgi.py, and I have ensured that my INSTALLED_APPS in settings.py includes all necessary applications:

INSTALLED_APPS = [
‘django.contrib.admin’,
‘django.contrib.auth’,
‘django.contrib.contenttypes’,
‘django.contrib.sessions’,
‘django.contrib.messages’,
‘django.contrib.staticfiles’,
‘Authentication’,
‘Cadastro’,
]

Here’s the content of my wsgi.py file:

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault(‘DJANGO_SETTINGS_MODULE’, ‘core.settings’)

application = get_wsgi_application()

And here is my Start Command:

gunicorn core.wsgi:application

Despite following the suggested structure and configurations, Gunicorn still cannot locate the core.wsgi module. I’ve also verified that all necessary __init__.py files are in place.

Has anyone encountered a similar issue or have any suggestions on how to resolve this? Any help would be greatly appreciated.

Thank you!

Hi there,

I think your start command should be gunicorn core.core.wsgi:application seeing the wsgi.py file is under core/core.

Regards,

Keith
Render Support, UTC+10 :australia:

I tried and it didn’t work. I believe I have already tested most of the possibilities, including trying to modify my wsgi file :smiling_face_with_tear:

==> Running ‘gunicorn core.core.wsgi:application’

Jun 17 10:45:33 PMTraceback (most recent call last):

Jun 17 10:45:33 PM File “/opt/render/project/src/.venv/bin/gunicorn”, line 8, in

Jun 17 10:45:33 PM sys.exit(run())

Jun 17 10:45:33 PM ^^^^^

Jun 17 10:45:33 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py”, line 67, in run

Jun 17 10:45:33 PM WSGIApplication(“%(prog)s [OPTIONS] [APP_MODULE]”, prog=prog).run()

Jun 17 10:45:33 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/gunicorn/app/base.py”, line 236, in run

Jun 17 10:45:33 PM super().run()

Jun 17 10:45:33 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/gunicorn/app/base.py”, line 72, in run

Jun 17 10:45:33 PM Arbiter(self).run()

Jun 17 10:45:33 PM ^^^^^^^^^^^^^

Jun 17 10:45:33 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/gunicorn/arbiter.py”, line 58, in init

Jun 17 10:45:33 PM self.setup(app)

Jun 17 10:45:33 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/gunicorn/arbiter.py”, line 118, in setup

Jun 17 10:45:35 PM==> Common ways to troubleshoot your deploy: Troubleshooting Your Deploy | Render Docs

Jun 17 10:45:33 PM self.app.wsgi()

Jun 17 10:45:33 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/gunicorn/app/base.py”, line 67, in wsgi

Jun 17 10:45:33 PM self.callable = self.load()

Jun 17 10:45:33 PM ^^^^^^^^^^^

Jun 17 10:45:33 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py”, line 58, in load

Jun 17 10:45:33 PM return self.load_wsgiapp()

Jun 17 10:45:33 PM ^^^^^^^^^^^^^^^^^^^

Jun 17 10:45:33 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py”, line 48, in load_wsgiapp

Jun 17 10:45:33 PM return util.import_app(self.app_uri)

Jun 17 10:45:33 PM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Jun 17 10:45:33 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/gunicorn/util.py”, line 371, in import_app

Jun 17 10:45:33 PM mod = importlib.import_module(module)

Jun 17 10:45:33 PM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Jun 17 10:45:33 PM File “/usr/local/lib/python3.11/importlib/init.py”, line 126, in import_module

Jun 17 10:45:33 PM return _bootstrap._gcd_import(name[level:], package, level)

Jun 17 10:45:33 PM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Jun 17 10:45:33 PM File “”, line 1204, in _gcd_import

Jun 17 10:45:33 PM File “”, line 1176, in _find_and_load

Jun 17 10:45:33 PM File “”, line 1147, in _find_and_load_unlocked

Jun 17 10:45:33 PM File “”, line 690, in _load_unlocked

Jun 17 10:45:33 PM File “”, line 940, in exec_module

Jun 17 10:45:33 PM File “”, line 241, in _call_with_frames_removed

Jun 17 10:45:33 PM File “/opt/render/project/src/core/core/wsgi.py”, line 16, in

Jun 17 10:45:33 PM application = get_wsgi_application()

Jun 17 10:45:33 PM ^^^^^^^^^^^^^^^^^^^^^^

Jun 17 10:45:33 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/django/core/wsgi.py”, line 12, in get_wsgi_application

Jun 17 10:45:33 PM django.setup(set_prefix=False)

Jun 17 10:45:33 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/django/init.py”, line 19, in setup

Jun 17 10:45:33 PM configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)

Jun 17 10:45:33 PM ^^^^^^^^^^^^^^^^^^^^^^^

Jun 17 10:45:33 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/django/conf/init.py”, line 92, in getattr

Jun 17 10:45:33 PM self._setup(name)

Jun 17 10:45:33 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/django/conf/init.py”, line 79, in _setup

Jun 17 10:45:33 PM self._wrapped = Settings(settings_module)

Jun 17 10:45:33 PM ^^^^^^^^^^^^^^^^^^^^^^^^^

Jun 17 10:45:33 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/django/conf/init.py”, line 190, in init

Jun 17 10:45:33 PM mod = importlib.import_module(self.SETTINGS_MODULE)

Jun 17 10:45:33 PM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Jun 17 10:45:33 PM File “/usr/local/lib/python3.11/importlib/init.py”, line 126, in import_module

Jun 17 10:45:33 PM return _bootstrap._gcd_import(name[level:], package, level)

Jun 17 10:45:33 PM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Jun 17 10:45:33 PM File “”, line 1204, in _gcd_import

Jun 17 10:45:33 PM File “”, line 1176, in _find_and_load

Jun 17 10:45:33 PM File “”, line 1140, in _find_and_load_unlocked

Jun 17 10:45:33 PMModuleNotFoundError: No module named ‘core.settings’

Hi there,

I think because of the way your project is structured you also need to have s.environ.setdefault(‘DJANGO_SETTINGS_MODULE’, ‘core.settings’) using core.core.setting. To be honest I’m not sure why your have the top level, core directory.

Regards,

Keith
Render Support, UTC+10 :australia:

When I do this, it stops recognizing my module

==> Running ‘gunicorn core.core.wsgi:application’

Jun 17 11:24:13 PMTraceback (most recent call last):

Jun 17 11:24:13 PM File “/opt/render/project/src/.venv/bin/gunicorn”, line 8, in

Jun 17 11:24:13 PM sys.exit(run())

Jun 17 11:24:13 PM ^^^^^

Jun 17 11:24:13 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py”, line 67, in run

Jun 17 11:24:13 PM WSGIApplication(“%(prog)s [OPTIONS] [APP_MODULE]”, prog=prog).run()

Jun 17 11:24:13 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/gunicorn/app/base.py”, line 236, in run

Jun 17 11:24:13 PM super().run()

Jun 17 11:24:13 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/gunicorn/app/base.py”, line 72, in run

Jun 17 11:24:13 PM Arbiter(self).run()

Jun 17 11:24:13 PM ^^^^^^^^^^^^^

Jun 17 11:24:13 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/gunicorn/arbiter.py”, line 58, in init

Jun 17 11:24:13 PM self.setup(app)

Jun 17 11:24:13 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/gunicorn/arbiter.py”, line 118, in setup

Jun 17 11:24:13 PM self.app.wsgi()

Jun 17 11:24:13 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/gunicorn/app/base.py”, line 67, in wsgi

Jun 17 11:24:13 PM self.callable = self.load()

Jun 17 11:24:13 PM ^^^^^^^^^^^

Jun 17 11:24:13 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py”, line 58, in load

Jun 17 11:24:13 PM return self.load_wsgiapp()

Jun 17 11:24:13 PM ^^^^^^^^^^^^^^^^^^^

Jun 17 11:24:13 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py”, line 48, in load_wsgiapp

Jun 17 11:24:13 PM return util.import_app(self.app_uri)

Jun 17 11:24:13 PM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Jun 17 11:24:13 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/gunicorn/util.py”, line 371, in import_app

Jun 17 11:24:13 PM mod = importlib.import_module(module)

Jun 17 11:24:13 PM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Jun 17 11:24:13 PM File “/usr/local/lib/python3.11/importlib/init.py”, line 126, in import_module

Jun 17 11:24:13 PM return _bootstrap._gcd_import(name[level:], package, level)

Jun 17 11:24:13 PM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Jun 17 11:24:13 PM File “”, line 1204, in _gcd_import

Jun 17 11:24:13 PM File “”, line 1176, in _find_and_load

Jun 17 11:24:13 PM File “”, line 1147, in _find_and_load_unlocked

Jun 17 11:24:13 PM File “”, line 690, in _load_unlocked

Jun 17 11:24:13 PM File “”, line 940, in exec_module

Jun 17 11:24:13 PM File “”, line 241, in _call_with_frames_removed

Jun 17 11:24:13 PM File “/opt/render/project/src/core/core/wsgi.py”, line 16, in

Jun 17 11:24:13 PM application = get_wsgi_application()

Jun 17 11:24:13 PM ^^^^^^^^^^^^^^^^^^^^^^

Jun 17 11:24:13 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/django/core/wsgi.py”, line 12, in get_wsgi_application

Jun 17 11:24:13 PM django.setup(set_prefix=False)

Jun 17 11:24:13 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/django/init.py”, line 24, in setup

Jun 17 11:24:13 PM apps.populate(settings.INSTALLED_APPS)

Jun 17 11:24:13 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/django/apps/registry.py”, line 91, in populate

Jun 17 11:24:13 PM app_config = AppConfig.create(entry)

Jun 17 11:24:13 PM ^^^^^^^^^^^^^^^^^^^^^^^

Jun 17 11:24:13 PM File “/opt/render/project/src/.venv/lib/python3.11/site-packages/django/apps/config.py”, line 193, in create

Jun 17 11:24:13 PM import_module(entry)

Jun 17 11:24:13 PM File “/usr/local/lib/python3.11/importlib/init.py”, line 126, in import_module

Jun 17 11:24:13 PM return _bootstrap._gcd_import(name[level:], package, level)

Jun 17 11:24:13 PM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Jun 17 11:24:13 PM File “”, line 1204, in _gcd_import

Jun 17 11:24:13 PM File “”, line 1176, in _find_and_load

Jun 17 11:24:13 PM File “”, line 1140, in _find_and_load_unlocked

Jun 17 11:24:13 PMModuleNotFoundError: No module named ‘Authentication’

Hi there,

This is likely to be the same issue as previously mentioned. You should get this working locally first. However, when running locally, you should run it from the top level core directory, so it runs in a similar fashion to how you are trying to run it on Render.

Regards,

Keith
Render Support, UTC+10 :australia: