Docker + Postgres : "lsof -i tcp:5432" lists nothing

  docker, postgresql, tcp

This is the result from systemctl status postgresql.service

● postgresql.service - PostgreSQL database server
     Loaded: loaded (/usr/lib/systemd/system/postgresql.service; disabled; vendor preset: disabled)
     Active: active (running) since Wed 2021-07-21 19:11:20 ACST; 15min ago
    Process: 14734 ExecStartPre=/usr/libexec/postgresql-check-db-dir postgresql (code=exited, status=0/SUCCESS)
   Main PID: 14736 (postmaster)
      Tasks: 8 (limit: 23759)
     Memory: 26.0M
        CPU: 421ms
     CGroup: /system.slice/postgresql.service
             ├─14736 /usr/bin/postmaster -D /var/lib/pgsql/data
             ├─14737 postgres: logger
             ├─14739 postgres: checkpointer
             ├─14740 postgres: background writer
             ├─14741 postgres: walwriter
             ├─14742 postgres: autovacuum launcher
             ├─14743 postgres: stats collector

This is the result from ss -tulnp | grep 5432

tcp   LISTEN 0      244                               0.0.0.0:5432       0.0.0.0:*                                      
tcp   LISTEN 0      244                                  [::]:5432          [::]:* 

This is the result from netstat -nlt | grep 5432

Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN
tcp6       0      0 :::5432                 :::*                    LISTEN

This is the result from lsof -i tcp:5432: nothing is displayed

I suppose this is the reason why I cant get Docker to connect to it. I get the following error
could not connect to server: Connection refused Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432?

Thank you for your help!

Source: Docker Questions

LEAVE A COMMENT