At the startup of the docker application (with laravel php), for 1 request, connection to database is fine. After the first request I start to get this error.
SQLSTATE[08006] [7] could not send SSL negotiation packet: Resource temporarily unavailable (Connection: pgsql, SQL: (select * from ........)
Using:
- Laravel v10 and above.
- PHP 8.3 and above
- Docker with Ubuntu Latest
I tracked down this problem until I found out that PDO is actually not openning a connection to PostgreSQL. I tested it with iptraf and both pg_connect and PDO. When we use PDO, we get the error above and but when I try to use pg_connect, we can connect and even make a query.
So my findings are, when using iptraf
- Cannot open a connection using PDO
- IPTraf does not show connection openned with PDO
- I can open a connection using pg_connect
- I can open a connection from a database manager application
- Happening on both development and production environments
- The whole setup is working on a virtual machine rather then a docker.
2
Answers
I want to add some clarifying information as my client and I experience the exact same issue starting after
unattended-upgrades
updated our PHP installation fromPHP 8.2.19
toPHP 8.2.20
We have been able to conclude the following
PHP 8.1.x
is completely unaffected by this issue. We created a temporary php script that connected to the Digital Ocean PostgreSQL database andPHP 8.1
was successfully able to connectPHP 8.2.20
onUbuntu 22.04 LTS
is affected by this issue. The same script that is described above did not work withPHP 8.2.20
PHP 8.2.20
on a Laravel Herd Windows installation connecting to Digital Ocean PostgreSQLphp8.2 artisan db
and successfully were dropped a shell into PostgreSQLPHP 8.2.20
, but do not know if these are correlatedCheck the php-swoole package version on your failed deployment.
If it is 6.0.0 probably you have here the problem.