Skip to content

Connection refused from app container to postgresql #55

@richhl

Description

@richhl

I'm getting SQLSTATE[08006] [7] could not connect to server: Connection refused
Is the server running on host "localhost" and accepting
TCP/IP connections on port 15432 when connecting from app container htttp://localhost:8000

My app/config/parameters.yml:

parameters:
    database_driver: pdo_pgsql
    database_host: localhost
    database_port: 15432
    *****

My docker ps output at host:

$ docker ps

CONTAINER ID        IMAGE                     COMMAND                  CREATED             STATUS              PORTS                                                                          NAMES

0dcfd05e6225        tfgnextentorno_app        "/opt/docker/bin/e..."   40 minutes ago      Up 11 minutes       9000/tcp, 0.0.0.0:10022->22/tcp, 0.0.0.0:8000->80/tcp, 0.0.0.0:8443->443/tcp  tfgnextentorno_app_1

9077cc959ec8        tfgnextentorno_postgres   "/docker-entrypoin..."   49 minutes ago      Up 11 minutes       0.0.0.0:15432->5432/tcp                                                        tfgnextentorno_postgres_1

230771a097d2        app_web                   "/usr/bin/supervisord"   About an hour ago   Up About an hour                                                                                   app_web_1

b066892ac462        mailhog/mailhog           "MailHog"                2 hours ago         Up 11 minutes       1025/tcp, 8025/tcp

My netstat output at host:

$> netstat -at
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State 
....
tcp6       0      0 [::]:15432              [::]:*                  LISTEN     
tcp6       0      0 [::]:57741              [::]:*                  LISTEN     
tcp6       0      0 [::]:sunrpc             [::]:*                  LISTEN     
tcp6       0      0 [::]:45904              [::]:*                  LISTEN     
tcp6       0      0 [::]:55762              [::]:*                  LISTEN     
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN     
tcp6       0      0 localhost:ipp           [::]:*                  LISTEN     
tcp6       1      0 localhost:59728         localhost:ipp           CLOSE_WAIT 

I have tried ::1, 127.0.0.1 as host address at parameters.yml but got same result. I can connect to postgresql container from the host but not able to do it from app container.

Thx in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions