pass_proxy not listening to containers using nginx in docker

I’m preparing a docker based dev environment for node and nginx but for some reason the nginx pass_proxy is not pointing to the container using their service name.

Here are the configuration files:


server {
    listen 80;
    error_log /var/log/nginx/error.log;
    location /api {
        proxy_pass http://web:3000;

nginx Dockerfile

FROM nginx:1.17-alpine
COPY ./default.conf /etc/nginx/conf.d/default.conf
CMD ["/bin/sh", "-c", "exec nginx -g 'daemon off;'"]


version: '3.3'

    build: ../backend
    container_name: backend
    restart: always
      - ../backend:/usr/src/app
      - /usr/src/app/node_modules
      - 6060:3000
    build: .
    restart: always
    container_name: nginx_server
      - ./log-nginx:/var/log/nginx/
      - web
      - 6000:80

I have exposed the web as well and it works when i visit localhost:6060 but if i go to the nginx endpoint by going to this address localhost:6000/api it shows an error page in the browser:

This site can’t be reached

Note that in the default.conf file i have tried using different variations for the pass_proxy container name, for example:

  • proxy_pass http://web;
  • proxy_pass http://web:3000;
  • proxy_pass web:3000;
  • proxy_pass web;

but it seems like non of them are working for nginx to shine. The logs file of nginx are also empty! what I might be missing here? Any help would be really helpful :) One more thing, I am using the alpine based official images.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.


I think that you would need to create a Docker Network and attach the 2 containers to that Network. That way you would be able to connect from container 1 to container 2 by name.

You could take a look at this answer here on how to do that:

Hope that this helps! Regards, Bobby