4

I've been following the tutorial on https://devcenter.heroku.com/articles/django#declare-process-types-with-procfile. It went smoothly except for one thing that bothers me.

After starting foreman I should see the following:

$ foreman start
2013-04-03 16:11:22 [8469] [INFO] Starting gunicorn 0.17.2
2013-04-03 16:11:22 [8469] [INFO] Listening at: http://127.0.0.1:8000 (8469)

However, I get:

Starting gunicorn 17.5
Listening at: http://0.0.0.0:5000

How can I change it so that it listens only to my local machine (ie. 127.0.0.1)?

My Procfile contains only

web: gunicorn hellodjango.wsgi

thanks!

Hamlet
  • 63
  • 1
  • 5
  • are you sure you're using foreman locally? `http://0.0.0.0:5000` is the standard public URL that heroku provides when you push your project to them. – agconti Aug 22 '13 at 11:29
  • At that stage in the tutorial there was no pushing to heroku (there wasn't even a git repo). Is gunicorn's default binding 127.0.0.1:8000 or 0.0.0.0:5000? – Hamlet Aug 22 '13 at 19:07
  • I believe local it's 127 and on heroku 0.0.0. – agconti Aug 22 '13 at 19:15
  • so then in my case it is not configured properly because it doesn't seem be doing that (see my follow up question). – Hamlet Aug 23 '13 at 07:43
  • follow up question on http://stackoverflow.com/questions/18433550/gunicorn-on-heruko-binding-to-localhost-without-messing-up-deployment-to-heruko – Hamlet Aug 25 '13 at 20:51

1 Answers1

6

This looks to be the default IP address used when you run use gunicorn to serve a WSGI app with foreman.

Running your django app without foreman like this:

gunicorn hellodjango.wsgi:application

Will bind it to gunicorn's default, 127.0.0.1:8000

2013-08-23 00:02:54 [45352] [INFO] Starting gunicorn 17.5
2013-08-23 00:02:54 [45352] [INFO] Listening at: http://127.0.0.1:8000 (45352)
2013-08-23 00:02:54 [45352] [INFO] Using worker: sync
2013-08-23 00:02:54 [45355] [INFO] Booting worker with pid: 45355

And specifying in your Procfile which binding to use:

web: gunicorn -b 127.0.0.1:8000 hellodjango.wsgi

Will bind it to 127.0.0.1:8000, or whatever you specify.

00:06:26 web.1  | started with pid 45384
00:06:26 web.1  | 2013-08-23 00:06:26 [45384] [INFO] Starting gunicorn 17.5
00:06:26 web.1  | 2013-08-23 00:06:26 [45384] [INFO] Listening at: http://127.0.0.1:8000 (45384)
00:06:26 web.1  | 2013-08-23 00:06:26 [45384] [INFO] Using worker: sync
00:06:26 web.1  | 2013-08-23 00:06:26 [45387] [INFO] Booting worker with pid: 45387

I'd be interested to find exactly where foreman tells gunicorn to use 0.0.0.0 as a default.

Chris McKinnel
  • 14,694
  • 6
  • 64
  • 67
  • You've answered my question, thanks for that! And I too would like to know where the default is set. The tutorial skipped this part, since they got the 127.0.0.1 binding but didn't use the -b option in the gunicorn command. – Hamlet Aug 22 '13 at 19:03
  • @Hamlet I'm actually encountering this exact same problem today, with gunicorn laughing at `0.0.0.0`. This might be a good bug to report. Are you on Linux 13.04 too? – agconti Aug 28 '13 at 16:11
  • @agconti No, Mac OSX Lion. What were you using before, when you had it working correctly? – Hamlet Sep 02 '13 at 22:30
  • @Hamlet windows 8 surprisingly. – agconti Sep 03 '13 at 00:05
  • 1
    Interesting, I'm on OSX too - perhaps relevant? – Chris McKinnel Sep 03 '13 at 02:25
  • @ChrisMcKinnel Did you also encounter this problem? Btw, did you get a chance to take a look at the follow up question? – Hamlet Sep 03 '13 at 20:33