skip to Main Content

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
[EDIT] New findings:

  • The whole setup is working on a virtual machine rather then a docker.

2

Answers


  1. 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 from PHP 8.2.19 to PHP 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 and PHP 8.1 was successfully able to connect
    • PHP 8.2.20 on Ubuntu 22.04 LTS is affected by this issue. The same script that is described above did not work with PHP 8.2.20
    • The issue was not able to be replicated using the exact same PHP installation in Amazon against RDS
    • The issue was not replicated on PHP 8.2.20 on a Laravel Herd Windows installation connecting to Digital Ocean PostgreSQL
    • The issue was replicated using Digital Ocean PostgreSQL 13, 14, 15, and 16 in Digital Ocean
    • Using a fresh Laravel installation against the Digital Ocean PostgreSQL instance we ran php8.2 artisan db and successfully were dropped a shell into PostgreSQL
    • We noted there were SSL changes within PHP 8.2.20, but do not know if these are correlated
    Login or Signup to reply.
  2. Check the php-swoole package version on your failed deployment.
    If it is 6.0.0 probably you have here the problem.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search