title: Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections
body: <p>I'm getting the below error while giving docker-compose up.</p>
  
  <pre><code>springbootapp    | org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
  springbootapp    |      at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:280) ~[postgresql-42.2.8.jar!/:42.2.8]
  springbootapp    |      at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) ~[postgresql-42.2.8.jar!/:42.2.8]
  springbootapp    |      at org.postgresql.jdbc.PgConnection.&lt;init&gt;(PgConnection.java:195) ~[postgresql-42.2.8.jar!/:42.2.8]
  springbootapp    |      at org.postgresql.Driver.makeConnection(Driver.java:458) ~[postgresql-42.2.8.jar!/:42.2.8]
  springbootapp    |      at org.postgresql.Driver.connect(Driver.java:260) ~[postgresql-42.2.8.jar!/:42.2.8]
  springbootapp    |      at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[HikariCP-3.4.2.jar!/:na]
  springbootapp    |      at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:354) ~[HikariCP-3.4.2.jar!/:na]
  springbootapp    |      at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:202) ~[HikariCP-3.4.2.jar!/:na]
  springbootapp    |      at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:473) [HikariCP-3.4.2.jar!/:na]
  springbootapp    |      at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:554) [HikariCP-3.4.2.jar!/:na]
  springbootapp    |      at com.zaxxer.hikari.pool.HikariPool.&lt;init&gt;(HikariPool.java:115) [HikariCP-3.4.2.jar!/:na]
  springbootapp    |      at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) [HikariCP-3.4.2.jar!/:na]
  springbootapp    |      at org.flywaydb.core.internal.jdbc.JdbcUtils.openConnection(JdbcUtils.java:56) [flyway-core-6.0.8.jar!/:na]
  springbootapp    |      at org.flywaydb.core.internal.jdbc.JdbcConnectionFactory.&lt;init&gt;(JdbcConnectionFactory.java:80) [flyway-core-6.0.8.jar!/:na]
  springbootapp    |      at org.flywaydb.core.Flyway.execute(Flyway.java:438) [flyway-core-6.0.8.jar!/:na]
  springbootapp    |      at org.flywaydb.core.Flyway.migrate(Flyway.java:149) [flyway-core-6.0.8.jar!/:na]
  springbootapp    |      at org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer.afterPropertiesSet(FlywayMigrationInitializer.java:65) [spring-boot-autoconfigure-2.2.6.RELEASE.jar!/:2.2.6.RELEASE]
  </code></pre>
  
  <p><strong>Dockerfile:</strong></p>
  
  <pre><code>FROM openjdk:8-jdk-alpine
  VOLUME /tmp
  EXPOSE 8082
  RUN mkdir -p /app/
  RUN mkdir -p /app/logs/
  ADD target/household-0.0.1-SNAPSHOT.jar /app/app.jar
  ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-Dspring.profiles.active=container", "-jar", "/app/app.jar"]
  </code></pre>
  
  <p><strong>docker-compose.yml:</strong></p>
  
  <pre><code>version: '3.2'
  services:
  postgres:
      image: postgres:latest
      network_mode: bridge
      container_name: postgres
      volumes:
      - postgres-data:/var/lib/postgresql/data
      expose:
      - 5432
      ports:
      - 5434:5434
      environment:
          - POSTGRES_PASSWORD=
          - POSTGRES_USER=
          - POSTGRES_DB=test
      restart: unless-stopped
  # APP*****
  springbootapp:
      image: springbootapp:latest
      network_mode: bridge
      container_name: springbootapp
      expose:
      - 8080
      ports:
      - 8080:8080
      restart: unless-stopped
      depends_on:
      - postgres
      links:
      - postgres
  volumes:
  postgres-data:
  </code></pre>