title: Docker SQLSTATE[08006] for pgsql service only from php service
body: <p>Not sure if my title is accurate, but here's my issue. I am running a basic laravel site on Docker and cannot get the site itself to connect to the PostgreSQL service. I will post my <code>docker-compose.yml</code> below. When i run <code>php artisan migrate</code> i get no errors and it all works. I can even use my Postico PostgreSQL client to connect to the DB and run queries. But, when i try and connect to the DB from the site, it errors out saying this:</p>
  
  <pre><code>SQLSTATE[08006] [7] could not connect to server: Connection refused Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5433?
  </code></pre>
  
  <p>Here are my PostgreSQL client settings (which DO work):</p>
  
  <pre><code>Host: 127.0.0.1
  Port: 5433
  User: homestead
  Password: homestead
  Database: homestead
  </code></pre>
  
  <p>I have been messing around with different settings and things so here is my <code>docker-compose.yml</code>, although i'm sure there are things i don't need in there:</p>
  
  <pre><code>version: '2'
  
  services:
    php:
      image: jguyomard/laravel-php:7.2
      build:
        context: .
        dockerfile: infrastructure/php/Dockerfile
      volumes:
        - ./:/var/www/
        - $HOME/.composer/:$HOME/.composer/
      networks:
        - default
      links:
        - postgresql
        - redis
  
    nginx:
      image: jguyomard/laravel-nginx:1.13
      build:
        context: .
        dockerfile: infrastructure/nginx/Dockerfile
      ports:
        - 81:80
      networks:
        - default
      links:
        - postgresql
        - redis
  
    postgresql:
      image: postgres:9.6-alpine
      volumes:
        - pgsqldata:/var/lib/postgresql/data
      environment:
        - "POSTGRES_DB=homestead"
        - "POSTGRES_USER=homestead"
        - "POSTGRES_PASSWORD=homestead"
      ports:
        - "5433:5432"
      networks:
        - default
  
    redis:
      image: redis:4.0-alpine
      command: redis-server --appendonly yes
      ports:
        - "6379:6379"
      networks:
        - default
  
  #  elastic:
  #    image: elasticsearch:5.5-alpine
  #    ports:
  #        - "9200:9200"
  
  volumes:
    pgsqldata:
  
  networks:
    default:
  </code></pre>
  
  <p>Any thoughts on why the site can't connect to the DB?</p>
  
  <p>My <code>docker network ls</code> output:</p>
  
  <pre><code>NETWORK ID      NAME               DRIVER        SCOPE
  2bf85424f466    bridge             bridge        local
  c29d413f768e    host               host          local
  0bdf9db30cd8    none               null          local
  f3d9cb028ae3    my-app_default     bridge        local
  </code></pre>