I am trying to debug this issue using Heroku's Foreman app. My issue is that Foreman is trying to run the process on port 5000 and at ip address 0.0.0.0. It says there is something using the port but I am not sure how to figure that out as I have nothing else running. I tried running 'netstat -lnt | grep 5000' with nothing.
> foreman start
11:16:45 web.1 | started with pid 17758
11:16:46 web.1 | 2013-12-31 11:16:46 [17758] [INFO] Starting gunicorn 18.0
11:16:46 web.1 | 2013-12-31 11:16:46 [17758] [ERROR] Connection in use: ('0.0.0.0', 5000)
11:16:46 web.1 | 2013-12-31 11:16:46 [17758] [ERROR] Retrying in 1 second.
11:16:47 web.1 | 2013-12-31 11:16:47 [17758] [ERROR] Connection in use: ('0.0.0.0', 5000)
11:16:47 web.1 | 2013-12-31 11:16:47 [17758] [ERROR] Retrying in 1 second.
I run the gunicorn command by it's self and it works fine (so I was able to eliminate that as an issue):
> gunicorn hellodjango.wsgi
2013-12-31 11:25:33 [17853] [INFO] Starting gunicorn 18.0
2013-12-31 11:25:33 [17853] [INFO] Listening at: http://127.0.0.1:8000 (17853)
2013-12-31 11:25:33 [17853] [INFO] Using worker: sync
2013-12-31 11:25:33 [17856] [INFO] Booting worker with pid: 17856
I am running this on my Mac (10.8).
Any insight on how to figure this out would be greatly appreciated.
-rb
Upon further investigation, I discovered that 0.0.0.0:5000 is used by Bonjour, Apple's network discovery app. Looking into how to change the port for Foreman next.
Figured this all out.
Solve is to manually set the port in the env and run foreman that way.
export PORT=5001
then
> foreman start
13:22:23 web.1 | started with pid 18194
13:22:24 web.1 | 2013-12-31 13:22:24 [18194] [INFO] Starting gunicorn 18.0
13:22:24 web.1 | 2013-12-31 13:22:24 [18194] [INFO] Listening at: http://0.0.0.0:5001 (18194)
13:22:24 web.1 | 2013-12-31 13:22:24 [18194] [INFO] Using worker: sync
13:22:24 web.1 | 2013-12-31 13:22:24 [18197] [INFO] Booting worker with pid: 18197
I imagine this will be an issue for everyone on OSX and hopefully this will save some headaches.
-rb
responding here as this page is the top listing on Google for 'Connection in use: ('0.0.0.0', 5000)'
The answer at Virtual env: Connection in use error worked perfectly for me:
you can find the id for unicorn to kill it via ps ax|grep unicorn and then using the id of the gunicorn instance kill <id>
I couldn't find a gunicorn process running to kill and none of the other suggestions worked for me so I tried restarting my Mac (OSX 10.9.2) with the "Reopen windows when logging back in" checkbox unchecked and after rebooting it started working again.
Related
I spent a whole day on investigating this issue but can't figure it out. Although I followed the correct command as the Celery docs said: celery -A tasks worker -l info
But I still received an error saying that
You are using `-A` as an option of the worker sub-command:
celery worker -A celeryapp <...>
The support for this usage was removed in Celery 5.0. Instead you should use `-A` as a global option:
celery -A celeryapp worker <...>
In my Dockerfile for Celery, my command to execute Celery was:
ENTRYPOINT ["celery", "-A", "tasks", "worker", "-l", "info"]
In the Heroku Resource, it still shows the expected command:
But then when the Heroku is building, I've received this error
2021-10-06T15:33:34.586677+00:00 heroku[web.1]: Starting process with command `gunicorn app:app`
2021-10-06T15:33:34.937996+00:00 heroku[celery_worker.1]: Starting process with command `celery -A tasks worker -l info`
2021-10-06T15:33:35.568289+00:00 heroku[celery_worker.1]: State changed from starting to up
2021-10-06T15:33:35.839353+00:00 heroku[web.1]: State changed from starting to up
2021-10-06T15:33:35.598861+00:00 app[web.1]: [2021-10-06 15:33:35 +0000] [4] [INFO] Starting gunicorn 20.1.0
2021-10-06T15:33:35.599401+00:00 app[web.1]: [2021-10-06 15:33:35 +0000] [4] [INFO] Listening at: http://0.0.0.0:21157 (4)
2021-10-06T15:33:35.599471+00:00 app[web.1]: [2021-10-06 15:33:35 +0000] [4] [INFO] Using worker: sync
2021-10-06T15:33:35.604608+00:00 app[web.1]: [2021-10-06 15:33:35 +0000] [6] [INFO] Booting worker with pid: 6
2021-10-06T15:33:43.827079+00:00 app[celery_worker.1]: You are using `-A` as an option of the worker sub-command:
2021-10-06T15:33:43.827086+00:00 app[celery_worker.1]: celery worker -A celeryapp <...>
2021-10-06T15:33:43.827086+00:00 app[celery_worker.1]:
2021-10-06T15:33:43.827093+00:00 app[celery_worker.1]: The support for this usage was removed in Celery 5.0. Instead you should use `-A` as a global option:
2021-10-06T15:33:43.827093+00:00 app[celery_worker.1]: celery -A celeryapp worker <...>
2021-10-06T15:33:43.830304+00:00 app[celery_worker.1]: Usage: celery worker [OPTIONS]
2021-10-06T15:33:43.830306+00:00 app[celery_worker.1]: Try 'celery worker --help' for help.
2021-10-06T15:33:43.830307+00:00 app[celery_worker.1]:
2021-10-06T15:33:43.831352+00:00 app[celery_worker.1]: Error: no such option: -A
Did I make something wrong or missing something in the configuration?
I'd be very glad to get your help. Thank you very much in advance.
I am working on a Windows 10 machine using Ubuntu inside WSL. I did this because I cannot get gunicorn to work as I've researched it is not available in Windows. I can successfully run my app using my docker-compose file within my WSL Ubuntu perfectly fine. I then run the gunicorn myapp.wsgi command and the server spins up with the terminal giving me the following output:
[2021-09-16 19:11:53 +0000] [25] [INFO] Starting gunicorn 20.1.0
[2021-09-16 19:11:53 +0000] [25] [INFO] Listening at: http://127.0.0.1:8000 (25)
[2021-09-16 19:11:53 +0000] [25] [INFO] Using worker: sync
[2021-09-16 19:11:53 +0000] [26] [INFO] Booting worker with pid: 26
However, I cannot connect to my site at localhost:8000. I also did a curl request against the localhost:8000 from inside my docker container and got a 302 error.
I've researched using gunicorn, mod_wsgi and uwsgi, all given as options in the Django documentation. However, I want to use gunicorn or uwsgi to have access to either nginx or Apache (plus the documentation on mod_wsgi has a dead link for the windows install file). Does anyone have suggestions on how I can get this to work?
I am new to server and apps.
Currently, I have created an app on my aws instance.
gunicorn --threads 4 -b 0.0.0.0:5000 --access-logfile server.log --timeout 60 server:app
But I want to keep it running after I ssh the instance, how could I achieve this?
[2018-09-24 17:45:28 +0000] [8318] [INFO] Starting gunicorn 19.9.0
[2018-09-24 17:45:28 +0000] [8318] [INFO] Listening at:
http://0.0.0.0:5000 (8318)
[2018-09-24 17:45:28 +0000] [8318] [INFO] Using worker: threads
[2018-09-24 17:45:28 +0000] [8321] [INFO] Booting worker with pid: 8321
I have to use control+c to exit too at the moment.
add --daemon to your command line or use screen (https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-14-04)
I am trying to implement nginx + django + gunicorn for my project deployment. I am taking the help of following article:
http://tutos.readthedocs.io/en/latest/source/ndg.html . I followed the steps as described. Now, I am trying to start gunicorn. What am I getting at the screen is:
$ gunicorn ourcase.wsgi:application
[2016-05-19 19:24:25 +0000] [9290] [INFO] Starting gunicorn 19.5.0
[2016-05-19 19:24:25 +0000] [9290] [INFO] Listening at: http://127.0.0.1:8000 (9290)
[2016-05-19 19:24:25 +0000] [9290] [INFO] Using worker: sync
[2016-05-19 19:24:25 +0000] [9293] [INFO] Booting worker with pid: 9293
Since, I am new to nginx & gunicorn, I am not sure whether the above is an error or not. I am getting nothing in error log
cat /var/log/nginx/error.log
It prints nothing on the screen. Please help me to solve this.
That output means that the process is running. Which is what you want. You should try accessing the URL from the browser directly after running the command without pressing ctrl+c.
As a side note you can write a bash script to do this which will make it easier to add arguments to the gunicorn commands.
I have a gist that does just that. https://gist.github.com/marcusshepp/129c822e2065e20122d8
Let me know what other questions you might have and I'll add a comment.
I have Django app using StreamingHttpResponse that fails when gunicorn worker times out. Basically extending timeout is not an option as streaming can take longer as it depends on network speed. Web server won't time out as is actually doing something but gunicorn workers seems to not recognize it.
I am aware of a choice between sync and async workers supported by gunicorn and using for example gevent.
it starts:
gunicorn -D -p /path/to/django.pid --bind 127.0.0.1:8000 --workers 2 -k gevent --worker-connections 10 --max-requests 100 myapp.wsgi:application
gunicorn log:
[2016-01-21 15:12:34 +0000] [30333] [INFO] Listening at: ...
[2016-01-21 15:12:34 +0000] [30333] [INFO] Using worker: gevent
[2016-01-21 15:14:22 +0000] [30338] [DEBUG] GET /url/1/
[2016-01-21 15:14:22 +0000] [30338] [DEBUG] Closing connection.
[2016-01-21 15:14:24 +0000] [30343] [DEBUG] GET /download/1/
...
[2016-01-21 15:15:43 +0000] [30333] [CRITICAL] WORKER TIMEOUT (pid:30343)
[2016-01-21 15:15:43 +0000] [30343] [DEBUG] Closing connection.
[2016-01-21 15:15:43 +0000] [30343] [INFO] Worker exiting (pid: 30343)
[2016-01-21 15:15:43 +0000] [31203] [INFO] Booting worker with pid: 31203
nginx log
2016/01/21 15:15:43 [error] 23160#0: *10849 upstream prematurely closed connection while reading upstream...
Why deploying the same app using fastcgi and flup never exposed that problem? Anyone could advice?