Nginx – *2 connect() failed (111: Connection refused) while connecting to upstream

nginxruby-on-rails

2012/10/26 14:57:49 [error] 14180#0: *2 connect() failed (111: Connection refused) while connecting to upstream, client: 24.0.20.48, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:81/", host: "107.20.184.144"

This is the nginx error that I get which results in a 503 error. Not sure what to do about it. connect() failed (111: Connection refused) while connecting to upstream said to use php-fpm, but I'm using Rails, so I think it's a different error. Any help would be GREATLY appreciated.

Thank you

EDIT: If it matters, this machine has Apache2 running on port 81 it seems. Not sure what that has to do with Rails though…

Best Answer

nginx is trying to pass upstream to a web server on port 81, as you configured it.

However, you probably aren't running Rails on port 81; by default thin and some other Rails web servers listen on port 3000.

Double check the port number that your Rails app is listening on, and make sure it matches what you have configured in nginx.

You also need to make sure that the upstream server is actually running. It could just be stopped.