title: nginx: nginx reverse proxy works in server but not working on localhost
body: <p>I have a backend service that uses prisma/graphql. and backend is running on port 4001.
  This is the proxy-pass of my Nginx config file <code>proxy_pass:http://$host:4001</code></p>
  
  <p>when I run it from the server it works on both <code>http://server:4001</code> and <code>http://server</code>
  But, when I run it from localhost, I am getting the following error:</p>
  
  <p><code>no resolver defined to resolve localhost, client: 172.30.0.1, server: _, request: "GET / HTTP/1.1", host: "localhost"
  </code></p>
  
  <p>what causes this error and how to fix it?</p>
  
  <p>docker-compose:</p>
  
  <pre><code>backend:
      image: base
      command: &gt;
        sh -c "npm run deploy &amp;&amp; npm run start"
      env_file: ${ENV_FILE}
      ports:
        - '4001:4001'
      depends_on:
        - prisma
      restart: always
      volumes:
        - ./deploy/certs:/deploy/certs
  
    nginx:
      image: nginx:latest
      volumes:
        - ./deploy/certs:/deploy/certs
        - ./deploy/nginx/conf.d:/etc/nginx/conf.d
      ports:
        - 80:80/tcp
        - 443:443/tcp
      depends_on:
        - backend
      restart: always
      env_file: ${ENV_FILE}
  
  </code></pre>
  
  <p>nginx config:</p>
  
  <pre><code>server {
      listen 80 default_server;
      server_name _;
  
  location / {
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-For $remote_addr;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_pass http://$host:4001;
  
    }
  }
  </code></pre>