1

SOME BACKGROUND:

I have created a django app and I am at the point where I want to deploy it. I have looked at multiple options including wsgi but since the new mac os update came about, I can not install mod_wsgi because I do not have apxs or apxs2 on my computer, (Some discussion on web about rights to write in files, If you know more and would like to explain, please do.)

However, I looked into other options to try to deploy the app and I want to use Heroku. I have followed the dev guide for Django deployment until I reached the part where I test using "heroku local web".
THE ISSUE

The problem stems from here because the local mysql server uses the same port that the gunicorn is also trying to use. I have found similar posts on stackoverflow about 'connections in use' but none have shown how to change ports for gunicorn. I have found some open ports available on my localhost but everytime I try to change the mysql ports to those, the connection times out. Therefore, I would like to know how to change the port the Gunicorn connects to so it does not try to connect to the same default port as the mysql which is 3306.

I was serving the django project with the server it came with and the database I am using is mysql for local production. I am trying to connect locally with gunicorn and Heroku now because I feel that if this goes right locally it will probably go right when I attempt to put the project online.

ERROR GIVEN

10:38:52 PM web.1 |  [2017-01-08 22:38:52 -0500] [83200] [ERROR] Connection in use: ('0.0.0.0', 3306)
10:38:52 PM web.1 |  [2017-01-08 22:38:52 -0500] [83200] [ERROR] Retrying in 1 second.
10:38:53 PM web.1 |  [2017-01-08 22:38:53 -0500] [83200] [ERROR] Connection in use: ('0.0.0.0', 3306)
10:38:53 PM web.1 |  [2017-01-08 22:38:53 -0500] [83200] [ERROR] Retrying in 1 second.
10:38:54 PM web.1 |  [2017-01-08 22:38:54 -0500] [83200] [ERROR] Connection in use: ('0.0.0.0', 3306)
10:38:54 PM web.1 |  [2017-01-08 22:38:54 -0500] [83200] [ERROR] Retrying 

in 1 second.

MY PROFILE

web: gunicorn project_name.wsgi.application --log-file -

The gunicorn connects when I stop the mysql server, but I get an exception since the project can not connect to the databases.

--Thank you

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134
thatguy
  • 97
  • 9

2 Answers2

0

You can specify the port for Gunicorn as follows -

gunicorn --bind 127.0.0.1:8000

So basically the complete command would be

gunicorn --bind 127.0.0.1:8000 myproject.wsgi:application

You can change 8000 to any of your desired port number.

utkbansal
  • 2,787
  • 2
  • 26
  • 47
0

To install mod_wsgi on MacOS X see:

All you need to do is pip install mod_wsgi.

You can then use mod_wsgi-express on the command line to run it on an unprivileged port, with all configuration done for you.

Or, you can integrate it with existing Apache installation and manually configure it yourself by running mod_wsgi-express module-config and taking what it outputs and add it to the main Apache configuration for the system. Then add you specific WSGI application configuration to the Apache configuration file as well.

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134