I am following this YouTube tutorial on how to configure Nginx Server on Docker but I am getting the following error

proxy_1 | 2018/07/14 22:18:24 [error] 5#5: *1 connect() failed (111: Connection refused) while connecting to upstream, client:, server: , request: "GET / HTTP/1.1", upstream: "", host: "localhost"


version: '3'
        build: nodecluster
        - "49160:8000"
    build: proxy
    - "80:80"  


FROM node:8

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install
# If you are building your code for production
# RUN npm install --only=production

# Bundle app source
COPY . .

CMD [ "npm", "start" ]


FROM nginx:alpine

RUN rm /etc/nginx/conf.d/*

COPY proxy.conf /etc/nginx/conf .d/


listen 80;
server {
    location / {

enter image description here

I googled and looked through different forums for an answer no matter what I tried the connection refused error is still there. The is up and running and if I access it directly using / localhost:49160 it works but it never get redirected from proxy to or like when I used http://nodecluster:49160/ or whatever.


Your nginx is trying to connect to localhost port 49160, but your nodecluster is running on another container, which has some other IP address.

You need to find the correct destination for nginx proxy_pass directive and fix the statement.

  • I can directly access the node application at localhost:49160 the containers external port is 49160 internal port is 8000. I have configured that right . how else I can connect to and gets the correct output – Sachin Divakar Jul 15 '18 at 9:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.