Today, I was having issues connecting from a Laravel app to a PostgreSQL database on Digital Ocean.

The error message I was getting was the following:

SQLSTATE[08006] [7] could not connect to server: Resource temporarily unavailable.

The weird thing was that it was not happening on all servers, only the ones that were recently updates with the latest Ubuntu packages.

It took some time to figure out what was causing it, but thanks to StackOverflow, I figured out that the issue was. The solution was basically:

Check the php-swoole package version on your failed deployment. If it is 6.0.0 probably you have here the problem.

So, I checked the version of the php-swoole package on the server that was failing and it was indeed 6.0.0. I then removed the package and the issue was fixed.

sudo apt remove php8.3-swoole

The bug report can be found here.