Mends.One

Why isn't Unicorn serving up pages on localhost?

Unicorn, Heroku, Ruby On Rails

I have been using Thin & Heroku (Cedar) for my Rails 3 app quite happily, but I've just switched to Unicorn in order to get PDFKit working.

Following Heroku's instructions, I have created my first ever Procfile at the root of my app and given it this content:

web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb

When I type foreman start at the command line, I get:

14:31:46 web.1  | started with pid 699
14:31:48 web.1  | I, [2013-03-13T14:31:48.544196 #699]  INFO -- : Refreshing Gem list
14:31:55 web.1  | I, [2013-03-13T14:31:55.736480 #699]  INFO -- : listening on addr=0.0.0.0:5000 fd=13
14:31:55 web.1  | I, [2013-03-13T14:31:55.740045 #699]  INFO -- : master process ready
14:31:55 web.1  | I, [2013-03-13T14:31:55.899544 #712]  INFO -- : worker=1 ready
14:31:55 web.1  | I, [2013-03-13T14:31:55.900740 #711]  INFO -- : worker=0 ready
14:31:55 web.1  | I, [2013-03-13T14:31:55.911041 #713]  INFO -- : worker=2 ready

If I try load localhost:3000 in the browser, nothing further appears under foreman's ouput, and the browser says: "Oops! Google Chrome could not connect to localhost:3000."

And it seems Unicorn is not using Port 3000 at all, as while it is running I can still launch Thin by typing rails server, and when I do this I can once again load localhost:3000 in a browser.

What's going on and how do I fix it?

1
S
steven_noble
Jump to: Answer 1 Answer 2

Answers (2)

Scratch that. I can see now that Unicorn publishes to localhost:5000. To make it use localhost:3000, put a .foreman file that says port: 3000 at the root of your app.

6
S
steven_noble

you can start unicorn at port 3000

unicorn_rails --config-file config/unicorn.rb -p 3000
1
M
msroot

Related Questions