Error While Deploying a Django App on Railway.app

169 Views Asked by At

self.load_wsgi()

File "/opt/venv/lib/python3.11/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi

self.wsgi = self.app.wsgi()

^^^^^^^^^^^^^^^

File "/opt/venv/lib/python3.11/site-packages/gunicorn/app/base.py", line 67, in wsgi

self.callable = self.load()

^^^^^^^^^^^

File "/opt/venv/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py", line 58, in load

return self.load_wsgiapp()

^^^^^^^^^^^^^^^^^^^

File "/opt/venv/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp

return util.import_app(self.app_uri)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/opt/venv/lib/python3.11/site-packages/gunicorn/util.py", line 371, in import_app

mod = importlib.import_module(module)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/root/.nix-profile/lib/python3.11/importlib/init.py", line 126, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "", line 1204, in _gcd_import

File "", line 1176, in _find_and_load

File "", line 1140, in _find_and_load_unlocked

ModuleNotFoundError: No module named 'dostanaapp.wsgi'

[2023-11-17 02:46:30 +0000] [9] [INFO] Worker exiting (pid: 9)

[2023-11-17 02:46:30 +0000] [1] [ERROR] Worker (pid:9) exited with code 3

[2023-11-17 02:46:30 +0000] [1] [ERROR] Shutting down: Master

[2023-11-17 02:46:30 +0000] [1] [ERROR] Reason: Worker failed to boot.

[2023-11-17 02:47:22 +0000] [1] [INFO] Starting gunicorn 21.2.0

[2023-11-17 02:47:22 +0000] [1] [INFO] Listening at: http://0.0.0.0:6275 (1)

[2023-11-17 02:47:22 +0000] [1] [INFO] Using worker: sync

[2023-11-17 02:47:22 +0000] [9] [INFO] Booting worker with pid: 9

[2023-11-17 02:47:22 +0000] [9] [ERROR] Exception in worker process

Traceback (most recent call last):

File "/opt/venv/lib/python3.11/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker

worker.init_process()

File "/opt/venv/lib/python3.11/site-packages/gunicorn/workers/base.py", line 134, in init_process

self.load_wsgi()

File "/opt/venv/lib/python3.11/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi

self.wsgi = self.app.wsgi()

^^^^^^^^^^^^^^^

File "/opt/venv/lib/python3.11/site-packages/gunicorn/app/base.py", line 67, in wsgi

self.callable = self.load()

^^^^^^^^^^^

File "/opt/venv/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py", line 58, in load

return self.load_wsgiapp()

^^^^^^^^^^^^^^^^^^^

File "/opt/venv/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp

return util.import_app(self.app_uri)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/opt/venv/lib/python3.11/site-packages/gunicorn/util.py", line 371, in import_app

mod = importlib.import_module(module)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/root/.nix-profile/lib/python3.11/importlib/init.py", line 126, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "", line 1204, in _gcd_import

File "", line 1176, in _find_and_load

File "", line 1140, in _find_and_load_unlocked

ModuleNotFoundError: No module named 'dostanaapp.wsgi'

[2023-11-17 02:47:22 +0000] [9] [INFO] Worker exiting (pid: 9)

[2023-11-17 02:47:22 +0000] [1] [ERROR] Worker (pid:9) exited with code 3

[2023-11-17 02:47:22 +0000] [1] [ERROR] Shutting down: Master

[2023-11-17 02:47:22 +0000] [1] [ERROR] Reason: Worker failed to boot.

1

There are 1 best solutions below

0
On

Alright Guys So I fixed it myself, and here is solution: As shown in screenshot click on +Start command and add command python3 manage.py runserver

After that let it redeploy and watch out for logs, it will show you any missing package name, in my case pillow was missing. Add any missing packages in requirements.txt and after that check logs if there are no errors. Remove Start Command leave it empty and it will automatically start the Gunicorn server correctly.