I keep seeing the below error message's in the error log, I can access all of the resources but I'm unsure as to why the error is flagging.


[error] 13368#0: *449 connect() failed (111: Connection refused) while connecting to upstream, client: x.x.x.x, server: myserver.com, request: "GET /stories/mine HTTP/1.1", upstream: "http://[::1]:5000/stories/mine", host: "myserver.com"

My Nginx config

I'm passing the connection over to a node.js cluster running on port 5000. Can't see what I would have missed?

upstream api {
    server localhost:5000;

server {
    listen 80; 
    server_name myserver.com;
    root /home/user/_api;

# Logging 

error_log /home/user/log/api.error.log notice;
    location / {
        proxy_redirect off;
        proxy_set_header   X-Real-IP            $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
        proxy_set_header   Host                   $http_host;
        proxy_set_header   X-NginX-Proxy    true;
        proxy_set_header   Connection "";
        proxy_cache one;
        proxy_cache_key sfs$request_uri$scheme;
        proxy_pass         http://api;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
  • It's 2015 and i'm having this same problem. everytime a websocket message gets dropped this error appears in the log.
    – r3wt
    Apr 25, 2015 at 4:59

2 Answers 2


Nginx connects to nodjs on the IPv6 loopback [::1]. nodejs is probably just listening on IPv4.

Try setting

upstream api {
  • To those who are confused, change localhost to
    – kouton
    Jan 12, 2015 at 16:13
  • Any ideas if I have instead of localhost and this keeps happening?
    – Ken
    May 14, 2015 at 17:26
  • 3
    You should check if the service is listening. Try sudo netstat -pantu and look if the service is actually listening on the port. May 14, 2015 at 17:29
  • 1
    @ChristopherPerrin thanks for that advice. It helped me to realise that one of my pools wasn't listening on its port, and it turned out to be because another pool configuration was re-using the same name so overwriting its configuration
    – scrowler
    Jan 25, 2016 at 23:28
  • @RobbieAverill nice to hear that this answer is still helpful Jan 26, 2016 at 0:12

I got the same error. I am using docker. I found that the reason was that I used but had to use name of my docker container. Here is the example:

This is a snippet from my nginx config file and this was the reason was getting an error ...failed (111: Connection refused) while connecting to upstream...:

location / {

And this is what I use not and do not get this error anymore (a snippet from my nginx config). app-ui here is the name of my docker container with a React app:

location / {
    proxy_pass http://app-ui:5006;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .