Error module Django not found #2895

Closed
opened 2025-12-29 18:23:12 +01:00 by adam · 2 comments
Owner

Originally created by @mrb0033 on GitHub (Sep 22, 2019).

In a CentOs 7 installation of a netbox 2.6.4 instance using gunicorn and nginx the command
'gunicorn -c /opt/netbox/gunicorn_config.py netbox.wsgi' continually comes back with the error

"File "/usr/local/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base.py", line 129, in init_process
File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
File "/usr/local/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
File "/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
File "/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
File "/usr/local/lib/python3.6/site-packages/gunicorn/util.py", line 350, in import_app
File "/opt/netbox-2.6.4/netbox/netbox/wsgi.py", line 9, in
from django.core.wsgi import get_wsgi_application
ModuleNotFoundError: No module named 'django'
[2019-09-20 14:52:38 -0500] [30731] [INFO] Worker exiting (pid: 30731)
[2019-09-20 14:52:38 -0500] [30706] [INFO] Shutting down: Master
[2019-09-20 14:52:38 -0500] [30706] [INFO] Reason: Worker failed to boot."

the /opt/netbox/gunicorn_config.py file contains:
"
pythonpath = "/opt/netbox/netbox"
bind = "127.0.0.1:8001"
workers = 3
user = "nginx"
"

and the /etc/supervisor.d/netbox.conf file contains:
"
program:netbox]
command = gunicorn -c /opt/netbox/gunicorn_config.py netbox.wsgi
directory = /opt/netbox/netbox/
user = nginx
"
if I comment out the user in /etc/supervisor.d/netbox.conf or if I run the command

"/usr/local/bin/gunicorn --pythonpath "/opt/netbox/netbox" --bind "127.0.0.1:8001" --workers 3 netbox.wsgi"

the page will load. However, the terminal will not run as nginx it will only run it as root, but other files are being run as nginx as if I run: ps aux | grep nginx

the output is:
"
root 4868 0.0 0.0 112708 976 pts/0 S+ 16:27 0:00 grep --color=auto nginx
root 29731 0.0 0.0 125084 2292 ? Ss 14:38 0:00 nginx: master process /usr/sbin/nginx
nginx 29732 0.0 0.0 127692 4052 ? S 14:38 0:00 nginx: worker process
nginx 29733 0.0 0.0 127692 4052 ? S 14:38 0:00 nginx: worker process
nginx 29734 0.0 0.0 127692 4048 ? S 14:38 0:00 nginx: worker process
nginx 29735 0.0 0.0 127692 3596 ? S 14:38 0:00 nginx: worker process
nginx 29736 0.0 0.0 127692 3804 ? S 14:38 0:00 nginx: worker process
nginx 29737 0.0 0.0 127692 3596 ? S 14:38 0:00 nginx: worker process
nginx 29738 0.0 0.0 127692 3596 ? S 14:38 0:00 nginx: worker process
nginx 29739 0.0 0.0 127692 3800 ? S 14:38 0:00 nginx: worker process
"
Any way to run it as nginx instead of root?

Originally created by @mrb0033 on GitHub (Sep 22, 2019). In a CentOs 7 installation of a netbox 2.6.4 instance using gunicorn and nginx the command 'gunicorn -c /opt/netbox/gunicorn_config.py netbox.wsgi' continually comes back with the error "File "/usr/local/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base.py", line 129, in init_process File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi File "/usr/local/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi File "/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load File "/usr/local/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp File "/usr/local/lib/python3.6/site-packages/gunicorn/util.py", line 350, in import_app File "/opt/netbox-2.6.4/netbox/netbox/wsgi.py", line 9, in from django.core.wsgi import get_wsgi_application ModuleNotFoundError: No module named 'django' [2019-09-20 14:52:38 -0500] [30731] [INFO] Worker exiting (pid: 30731) [2019-09-20 14:52:38 -0500] [30706] [INFO] Shutting down: Master [2019-09-20 14:52:38 -0500] [30706] [INFO] Reason: Worker failed to boot." the /opt/netbox/gunicorn_config.py file contains: " pythonpath = "/opt/netbox/netbox" bind = "127.0.0.1:8001" workers = 3 user = "nginx" " and the /etc/supervisor.d/netbox.conf file contains: " program:netbox] command = gunicorn -c /opt/netbox/gunicorn_config.py netbox.wsgi directory = /opt/netbox/netbox/ user = nginx " if I comment out the user in /etc/supervisor.d/netbox.conf or if I run the command "/usr/local/bin/gunicorn --pythonpath "/opt/netbox/netbox" --bind "127.0.0.1:8001" --workers 3 netbox.wsgi" the page will load. However, the terminal will not run as nginx it will only run it as root, but other files are being run as nginx as if I run: ps aux | grep nginx the output is: " root 4868 0.0 0.0 112708 976 pts/0 S+ 16:27 0:00 grep --color=auto nginx root 29731 0.0 0.0 125084 2292 ? Ss 14:38 0:00 nginx: master process /usr/sbin/nginx nginx 29732 0.0 0.0 127692 4052 ? S 14:38 0:00 nginx: worker process nginx 29733 0.0 0.0 127692 4052 ? S 14:38 0:00 nginx: worker process nginx 29734 0.0 0.0 127692 4048 ? S 14:38 0:00 nginx: worker process nginx 29735 0.0 0.0 127692 3596 ? S 14:38 0:00 nginx: worker process nginx 29736 0.0 0.0 127692 3804 ? S 14:38 0:00 nginx: worker process nginx 29737 0.0 0.0 127692 3596 ? S 14:38 0:00 nginx: worker process nginx 29738 0.0 0.0 127692 3596 ? S 14:38 0:00 nginx: worker process nginx 29739 0.0 0.0 127692 3800 ? S 14:38 0:00 nginx: worker process " Any way to run it as nginx instead of root?
adam closed this issue 2025-12-29 18:23:12 +01:00
Author
Owner

@kobayashi commented on GitHub (Sep 22, 2019):

What is the name of netbox root directory?
Is that netbox-2.6.4? If so, you need to change the directory name or the path to run gunicorn.

@kobayashi commented on GitHub (Sep 22, 2019): What is the name of netbox root directory? Is that netbox-2.6.4? If so, you need to change the directory name or the path to run gunicorn.
Author
Owner

@jeremystretch commented on GitHub (Sep 23, 2019):

Thank you for your interest in NetBox. GitHub issues are intended for reporting reproducible bugs and requesting features, and must be submitted using one of the templates provided here. For general discussion, questions, or assistance with installation issues, please post to our mailing list instead.

@jeremystretch commented on GitHub (Sep 23, 2019): Thank you for your interest in NetBox. GitHub issues are intended for reporting reproducible bugs and requesting features, and must be submitted using one of the templates provided [here](https://github.com/digitalocean/netbox/issues/new/choose). For general discussion, questions, or assistance with installation issues, please post to our [mailing list](https://groups.google.com/forum/#!forum/netbox-discuss) instead.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2895