Home > Enterprise >  ModuleNotFoundError: No module named 'authentication.wsgi'
ModuleNotFoundError: No module named 'authentication.wsgi'

Time:12-09

I am trying to deploy my django project on production server but getting failure error while setting up the gunicorn. Any kind of help would be appreciated. Thanks in advance.

Below is the command I am running getting the error

gunicorn --bind 0.0.0.0:8000 authentication.wsgi

authentication is the name of application

Below is the error log

 [2022-12-08 14:52:29  0530] [79282] [INFO] Starting gunicorn 20.1.0
[2022-12-08 14:52:29  0530] [79282] [INFO] Listening at: http://0.0.0.0:8000 (79282)
[2022-12-08 14:52:29  0530] [79282] [INFO] Using worker: sync
[2022-12-08 14:52:29  0530] [79284] [INFO] Booting worker with pid: 79284
[2022-12-08 14:52:29  0530] [79284] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/home/web/.local/lib/python3.8/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
    worker.init_process()
  File "/home/web/.local/lib/python3.8/site-packages/gunicorn/workers/base.py", line 134, in init_process
    self.load_wsgi()
  File "/home/web/.local/lib/python3.8/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/home/web/.local/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/home/web/.local/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
    return self.load_wsgiapp()
  File "/home/web/.local/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/home/web/.local/lib/python3.8/site-packages/gunicorn/util.py", line 359, in import_app
    mod = importlib.import_module(module)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
**ModuleNotFoundError: No module named 'authentication.wsgi'**
[2022-12-08 14:52:29  0530] [79284] [INFO] Worker exiting (pid: 79284)
[2022-12-08 14:52:29  0530] [79282] [INFO] Shutting down: Master
[2022-12-08 14:52:29  0530] [79282] [INFO] Reason: Worker failed to boot.

highlighting error, ModuleNotFoundError: No module named 'authentication.wsgi

wsgi.py

    """
WSGI config for Database project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

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

application = get_wsgi_application()

Thanks.

CodePudding user response:

My Bad guys, It should be,

gunicorn --bind 0.0.0.0:8000 Database.wsgi

I got confused in project name and app name.

Thanks all for the quick response, I appreciate it.

CodePudding user response:

Go to dir that 'main project' folder exists, not from inside the main project folder then try again. The 'main project' is the folder that settings.py exists.

Try

gunicorn --bind 0.0.0.0:8000 authentication.wsgi:application

wsgi

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'authentication.settings')
  • Related