• Register
1 vote
906 views

Problem :

I am very new to Django. I have recently installed the Django app and now I am trying to set it up with the Gunicorn first and soon after with the Supervisor and Nginx. My Django app is running with a normal Django command as expected for example python manage.py runserver. I have already  installed my Gunicorn using the pip for example pip install gunicorn and my Django version is 1.5.3. But when I try to run a below command and it is inside a virtual env as shown below

gunicorn hello.wsgi:application -b xx.xxx.xxx.xx:8000

And getting the below error

Traceback (most recent call last):
  File "/root/Envs/proj/bin/gunicorn", line 9, in <module>
    load_entry_point('gunicorn==19.0.0', 'console_scripts', 'gunicorn')()
  File "/root/Envs/proj/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
    WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
  File "/root/Envs/proj/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 166, in run
    super(Application, self).run()
  File "/root/Envs/proj/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 71, in run
    Arbiter(self).run()
  File "/root/Envs/proj/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 169, in run
    self.manage_workers()
  File "/root/Envs/proj/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 477, in manage_workers
    self.spawn_workers()
  File "/root/Envs/proj/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 537, in spawn_workers
    time.sleep(0.1 * random.random())
  File "/root/Envs/proj/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 209, in handle_chld
    self.reap_workers()
  File "/root/Envs/proj/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 459, in reap_workers
    raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>

Can some expert help me in fixing above error?

9 6 2
3,980 points

Please log in or register to answer this question.

2 Answers

1 vote

Solution :

I have gone through your problem and I can assure that I have the quick fix for your issue. Your problem here is related to wsgi file itself in the past before the Django 1.3 a wsgi file was named with an extension of .wsgi, but now in the recent versions it will be created with and the extension of your .py that is a wsgi file must be the python module. So your file must be hello_wsgi.py and so your command should be as shown below:

gunicorn  hello:application -b xx.xxx.xxx.xx:8000
I hope you will be able to save your time in fixing your problem with the help of my above solution.
5 4 2
17,150 points
0 votes

Solution:

really the problem here was the wsgi file itself, formerly before django 1.3 the wsgi file was named with an extension of .wsgi, however now in the current versions it will be created with and extension of .py that is the wsgi file should be a python module

so the file must be hello_wsgi.py and command must be

gunicorn  hello:application -b xx.xxx.xxx.xx:8000

run guncorn with --preload can view the error log, like this

gunicorn app:application --preload -b 0.0.0.0:5000 

This will generally give you a more detailed error message.

You don't displayed a full output. It's possibly looks like

$ gunicorn elcarweb.wsgi
[2015-10-27 21:01:47 +0000] [5429] [INFO] Starting gunicorn 19.2.1
[2015-10-27 21:01:47 +0000] [5429] [INFO] Listening at: http://127.0.0.1:8000 (5429)
[2015-10-27 21:01:47 +0000] [5429] [INFO] Using worker: sync
[2015-10-27 21:01:47 +0000] [5434] [INFO] Booting worker with pid: 5434
[2015-10-27 21:01:47 +0000] [5434] [ERROR] Exception in worker process:
Traceback (most recent call last):
  File "/home/tomek/Elcar/elcarweb/env/lib/python2.7/site-packages/gunicorn/arbiter.py", line 503, in spawn_worker
    worker.init_process()
  File "/home/tomek/Elcar/elcarweb/env/lib/python2.7/site-packages/gunicorn/workers/base.py", line 116, in init_process
    self.wsgi = self.app.wsgi()
  File "/home/tomek/Elcar/elcarweb/env/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/home/tomek/Elcar/elcarweb/env/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
    return self.load_wsgiapp()
  File "/home/tomek/Elcar/elcarweb/env/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/home/tomek/Elcar/elcarweb/env/lib/python2.7/site-packages/gunicorn/util.py", line 355, in import_app
    __import__(module)
ImportError: No module named elcarweb.wsgi
Traceback (most recent call last):
  File "/home/tomek/Elcar/elcarweb/env/lib/python2.7/site-packages/gunicorn/arbiter.py", line 503, in spawn_worker
    worker.init_process()
  File "/home/tomek/Elcar/elcarweb/env/lib/python2.7/site-packages/gunicorn/workers/base.py", line 116, in init_process
    self.wsgi = self.app.wsgi()
  File "/home/tomek/Elcar/elcarweb/env/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/home/tomek/Elcar/elcarweb/env/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
    return self.load_wsgiapp()
  File "/home/tomek/Elcar/elcarweb/env/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/home/tomek/Elcar/elcarweb/env/lib/python2.7/site-packages/gunicorn/util.py", line 355, in import_app
    __import__(module)
ImportError: No module named elcarweb.wsgi
[2015-10-27 21:01:47 +0000] [5434] [INFO] Worker exiting (pid: 5434)
Traceback (most recent call last):
  File "/home/tomek/Elcar/elcarweb/env/bin/gunicorn", line 11, in <module>
    sys.exit(run())
  File "/home/tomek/Elcar/elcarweb/env/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
    WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
  File "/home/tomek/Elcar/elcarweb/env/lib/python2.7/site-packages/gunicorn/app/base.py", line 189, in run
    super(Application, self).run()
  File "/home/tomek/Elcar/elcarweb/env/lib/python2.7/site-packages/gunicorn/app/base.py", line 72, in run
    Arbiter(self).run()
  File "/home/tomek/Elcar/elcarweb/env/lib/python2.7/site-packages/gunicorn/arbiter.py", line 170, in run
    self.manage_workers()
  File "/home/tomek/Elcar/elcarweb/env/lib/python2.7/site-packages/gunicorn/arbiter.py", line 473, in manage_workers
    self.spawn_workers()
  File "/home/tomek/Elcar/elcarweb/env/lib/python2.7/site-packages/gunicorn/arbiter.py", line 537, in spawn_workers
    time.sleep(0.1 * random.random())
  File "/home/tomek/Elcar/elcarweb/env/lib/python2.7/site-packages/gunicorn/arbiter.py", line 210, in handle_chld
    self.reap_workers()
  File "/home/tomek/Elcar/elcarweb/env/lib/python2.7/site-packages/gunicorn/arbiter.py", line 455, in reap_workers
    raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>

 However before You view necessary informations:

ImportError: No module named elcarweb.wsgi

In case You view this error, then resolution is run gunicorn with --chdir=/your/app/dir parameter.

I also had a same error in Ubuntu 16.04, Django 1.11, employing systemd.

My issue was that I had split my settings out into separate files; for example: instead of having all settings in project/settings.py, I have a some settings files like project/settings/dev.py.

I had to update DJANGO_SETTINGS_MODULE in the project/wsgi.py file from:

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")  

to

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings.dev")

 

10 6 4
31,120 points

Related questions

0 votes
2 answers 149 views
149 views
I want to run a Django application in PyCharm which works on MySQL DB. I am unable to connect my program to the database. When I am trying to install MySQLclient or MySQL-python I am getting the error: Failed building wheel for MySQLclient Please help me out in connecting my Django program with MySQL database.
asked Oct 24, 2020 psandprop 2.4k points
0 votes
1 answer 16 views
16 views
Problem: no python application found, check your startup logs for errors.
asked Feb 21 charles mathews 3.8k points
0 votes
1 answer 12 views
12 views
I downloaded python 3.8.6 on windows 10 and need some guidance on how to install Django
asked Oct 1, 2020 turpotu 140 points
1 vote
1 answer 600 views
600 views
Problem : I am very new to Django. My current task is to store the form field variable with the help of Django cache and I have already added the Django form in my view. I am often facing below error and as I am very new to Django so unable to understand the below ...         form = Formulary() return render(request, 'form.html', {'form' : form}) I am looking for Django expert to fix above error.
asked May 1, 2020 stewart 4k points
1 vote
1 answer 35 views
35 views
Problem : I am very new to MySQL Server. I am newly assigned to this MySQL Server project. If I try to connect with the local MySQL server during my assigned test suite it shows me the below error: "Can't connect to local MySQL server through socket '/tmp/ ... that exception I can connect with my exact same parameters. I am very confused about above error. Can some expert help me in fixing it?
asked Apr 8, 2020 morrisBson 3.2k points
0 votes
1 answer 2.7K views
2.7K views
Problem : I want to deploy the Django application to a web, but I face the below error: &ldquo;You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path&rdquo;
asked Feb 3, 2020 jwilliam 3.9k points
0 votes
1 answer 309 views
309 views
Problem : I am not very sure how can I fix the below issue I have really no idea about why am I facing below error while trying to do the runserver: Performing system checks... System check identified no issues (0 silenced). Unhandled exception in thread ... server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
asked Dec 25, 2019 alecxe 7.5k points
0 votes
1 answer 607 views
607 views
Probem : I am getting bellow error new-line character seen in unquoted field - do you need to open the file in universal-newline mode?
asked Nov 7, 2019 peterlaw 6.9k points
0 votes
1 answer 52 views
52 views
Problem: I have this piece of code which creates a new note..WHen I try to print I get the following error even though it prints the output Error: C:\Python27\Basics\OOP\formytesting>python notebook.py Memo=This is my first memo, Tag=example Traceback (most recent call last): File "notebook.py", line 14, in <module> print(firstnote) TypeError: __str__ returned non-string (type NoneType)
asked Jan 8 Mashhoodch 10.1k points
0 votes
1 answer 44 views
44 views
Problem: I am trying to implement Social Login in Django. I have already installed social_auth_app_django with below command pip install social-auth-app-django And I also added this to installed apps in my settings file. INSTALLED_APPS = [ 'django.contrib.admin', ' ... migration python manage.py migrate ModuleNotFoundError : No module named mysite.core Note. I am using Python 3.6.2andDjango 1.11.7
asked Dec 25, 2020 sasha 13.2k points