title: Why can't I access my web app from a remote container?
body: <p>I have looked through past answers since this is a common question but no solution seems to work for me.</p>
  <p>I have a Springboot Java app and a postgresql database, each in their own container. Both containers run on a remote headless server on a local network. My remote server's physical IP address is 192.168.1.200. When I enter: 'http://192.168.1.200:8080' in my browser from another machine I get a 'unable to connect' response.</p>
  <p>Here is my Docker-compose file:</p>
  <pre><code>version: &quot;3.3&quot;
  services:
    db:
      image: postgres
      environment:
        POSTGRES_PASSWORD: aaa
      volumes:
        - /var/lib/postgresql/data 
      ports:
        - &quot;5432:5432&quot;
      networks:
        - nat
    
    web:
      image: email-viewer
      ports:
        - &quot;192.168.1.200:8080:80&quot;
      depends_on:
        - db
      networks:
        - nat
  networks:
    nat:
      external:
       name: nat 
  </code></pre>
  <p>Here is the output when I run docker-compose up:</p>
  <pre><code>Recreating email-viewer_db_1 ... done
  Recreating email-viewer_web_1 ... done
  Attaching to email-viewer_db_1, email-viewer_web_1
  db_1   | 
  db_1   | PostgreSQL Database directory appears to contain a database; Skipping initialization
  db_1   | 
  db_1   | 2022-05-06 16:13:24.300 UTC [1] LOG:  starting PostgreSQL 14.2 (Debian 14.2-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
  db_1   | 2022-05-06 16:13:24.300 UTC [1] LOG:  listening on IPv4 address &quot;0.0.0.0&quot;, port 5432
  db_1   | 2022-05-06 16:13:24.300 UTC [1] LOG:  listening on IPv6 address &quot;::&quot;, port 5432
  db_1   | 2022-05-06 16:13:24.305 UTC [1] LOG:  listening on Unix socket &quot;/var/run/postgresql/.s.PGSQL.5432&quot;
  db_1   | 2022-05-06 16:13:24.311 UTC [27] LOG:  database system was shut down at 2022-05-06 13:54:07 UTC
  db_1   | 2022-05-06 16:13:24.319 UTC [1] LOG:  database system is ready to accept connections
  web_1  | 
  web_1  |   .   ____          _            __ _ _
  web_1  |  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
  web_1  | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
  web_1  |  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  web_1  |   '  |____| .__|_| |_|_| |_\__, | / / / /
  web_1  |  =========|_|==============|___/=/_/_/_/
  web_1  |  :: Spring Boot ::                (v2.6.5)
  web_1  | 
  web_1  | 2022-05-06 16:13:25.487  INFO 1 --- [           main] c.a.emailviewer.EmailViewerApplication   : Starting EmailViewerApplication v0.0.1-SNAPSHOT using Java 17.0.2 on 1a13d69d117d with PID 1 (/app/email-viewer-0.0.1-SNAPSHOT.jar started by root in /app)
  web_1  | 2022-05-06 16:13:25.490  INFO 1 --- [           main] c.a.emailviewer.EmailViewerApplication   : No active profile set, falling back to 1 default profile: &quot;default&quot;
  web_1  | 2022-05-06 16:13:26.137  INFO 1 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
  web_1  | 2022-05-06 16:13:26.184  INFO 1 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 38 ms. Found 1 JPA repository interfaces.
  web_1  | 2022-05-06 16:13:26.764  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
  web_1  | 2022-05-06 16:13:26.774  INFO 1 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
  web_1  | 2022-05-06 16:13:26.775  INFO 1 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.60]
  web_1  | 2022-05-06 16:13:26.843  INFO 1 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
  web_1  | 2022-05-06 16:13:26.843  INFO 1 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1297 ms
  web_1  | 2022-05-06 16:13:27.031  INFO 1 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
  web_1  | 2022-05-06 16:13:27.077  INFO 1 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.6.7.Final
  web_1  | 2022-05-06 16:13:27.222  INFO 1 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
  web_1  | 2022-05-06 16:13:27.313  INFO 1 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
  web_1  | 2022-05-06 16:13:27.506  INFO 1 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
  web_1  | 2022-05-06 16:13:27.539  INFO 1 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL10Dialect
  web_1  | 2022-05-06 16:13:28.034  INFO 1 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
  web_1  | 2022-05-06 16:13:28.042  INFO 1 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
  web_1  | 2022-05-06 16:13:28.330  WARN 1 --- [           main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
  web_1  | 2022-05-06 16:13:28.663  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
  web_1  | 2022-05-06 16:13:28.672  INFO 1 --- [           main] c.a.emailviewer.EmailViewerApplication   : Started EmailViewerApplication in 3.615 seconds (JVM running for 4.024)
  
  </code></pre>