title: Docker container not accessible in host machine
body: <p>Some of my containers are running a web server (PHP, NodeJS) in production.</p>
  
  <p>If we take the example of the NodeJS container, this is its configuration</p>
  
  <p><strong>docker-compose.yml</strong></p>
  
  <pre><code>version: '2'
  services:
    webapp:
      build: .
      volumes_from:
       - data
      links:
       - db:db
       - redis:redis
      ports:
        - '8080:3000'
      restart: always
  
    ...
  </code></pre>
  
  <p>With this configuration, I'm able to access to my webapp through <code>http://example.com:8080/</code> but I cannot access on my host machine with</p>
  
  <pre><code>$ curl localhost:8080
  (Time-out)
  </code></pre>
  
  <p>I have a <em>Nginx</em> server on my host with this configuration:</p>
  
  <p><strong>example.com.conf</strong></p>
  
  <pre><code>upstream webapp {
     server 127.0.0.1:8080;
  }
  
  server {
    listen 80;
    listen [::]:80;
  
    server_name example.com;
  
    location / {
      proxy_set_header   X-Real-IP $remote_addr;
      proxy_set_header   HOST $http_host;
      proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header   X-NginX-Proxy true;
      proxy_redirect off;
  
      proxy_pass http://webapp;
    }
  
  }
  </code></pre>
  
  <p>But acceding to <code>http://example.com/</code> throw a 504 Gateway Time-out.</p>
  
  <p>If I try to change port configuration in my <code>docker-compose.yml</code> by <code>'127.0.0.1:8080:3000'</code> the problem still here but cannot access to <code>http://example.com</code> (and <code>http://example.com:8080</code> but it is the result I want).</p>
  
  <p>This is very strange and I don't have the problem running my app on a fresh server.
  I'm searching for the root of this issue.</p>
  
  <p>Thanks for your support.</p>
  
  <p>EDIT:</p>
  
  <pre><code>$ netstat -tunlp
  Active Internet connections (only servers)
  Proto Recv-Q Send-Q Local Address           Foreign Address        State       PID/Program name
  tcp        0      0 127.0.0.11:59712        0.0.0.0:*               LISTEN      -               
  udp        0      0 127.0.0.11:33293        0.0.0.0:*                           -               
  </code></pre>
  
  <p>Web server has to be listening on port 3000 but I have</p>
  
  <pre><code>$ docker-compose logs
  webapp_1  | Express server listening on port 3000 in production mode
  </code></pre>
  
  <p>The server is also running...</p>
  
  <pre><code>$ docker port webapp_1
  3000/tcp -&gt; 127.0.0.1:8080
  </code></pre>