Connection timeout on the PostgreSQL instance.

1,138 views
Skip to first unread message

Daniele Fois

unread,
Nov 27, 2019, 12:45:58 PM11/27/19
to Google Cloud SQL discuss

I have a Google Cloud PostgreSQL instance. I can connect to it by several local IP addresses, after having whitelisted them in the connections tab on GCP. I developed my application and now, when I try to connect the instance from production webserver, it says:

Fatal error: Uncaught PDOException: SQLSTATE[08006] [7] could not connect to server: Connection timed out Is the server running on host "34.65.215.xx" and accepting TCP/IP connections on port 5432? 

the PHP I'm using is:

$db2 = new PDO('pgsql:host=34.65.215.xx;port=5432;dbname=xxxxx', 'postgres', 'xxxxxx');

I wrote to my webserver support and they answered me by opening the 5432 port in output on the 34.65.215.xx IP. After that I still can't connect to the instance.

The strace says:

0.000120 socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 4
0.000043 setsockopt(4, SOL_TCP, TCP_NODELAY, [1], 4) = 0
0.000031 fcntl(4, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
0.000024 fcntl(4, F_SETFD, FD_CLOEXEC) = 0
0.000027 connect(4, {sa_family=AF_INET, sin_port=htons(5432), sin_addr=inet_addr("34.65.215.xx")}, 16) = -1 EINPROGRESS (Operation now in progress)
0.000112 poll([{fd=4, events=POLLOUT|POLLERR}], 1, 30000) = 1 ([{fd=4, revents=POLLOUT|POLLERR|POLLHUP}])
15.270417 getsockopt(4, SOL_SOCKET, SO_ERROR, [110], [4]) = 0
0.000103 close(4) = 0

I just don't know what to do next...

Can someone help to understand?

Elliott (Google Cloud Platform Support)

unread,
Nov 27, 2019, 6:45:04 PM11/27/19
to Google Cloud SQL discuss

Hello Daniele,


Please note that Google Groups are reserved for general Google Cloud Platform and product discussions and not for reporting issues, which is why I suggest moving the troubleshooting to Issue Tracker, where issues can be turned private in case we need to gather any project specific details.


Reply all
Reply to author
Forward
0 new messages