This syntax is incorrect. ‘server’ should be ‘host’ and then the connection would attempt to use the tcp/ip stack to make a connection, not a socket. Since it is attempting to use a socket, it’s likely that the unknown ‘server’ keyword defaults to ‘localhost’ which on your operating system attempts to use a socket.
If after correcting this syntax to use a socket, the error comes and goes on its own, it means that the database server is or is not running, and you should be troubleshooting why the database server is not running. If after correcting this syntax to use a socket, it always fails, it is most likely because there’s a mismatch in the socket setting between php and the database server.
Or, you can correct this syntax to actually use a tcp/ip connection, which it appears was the intent, based on the presence of the ip address of the database server, and see if the entire problem goes away.
Edit: I see in the previously posted connection function/code that ‘host’ was used. So, at this point, none of the provided information means anything. We don’t know why the previous code, which wasn’t producing any connection error information, was failing or if the last test code, which is producing connection error information, would have ever worked because of the socket settings.