Sqlstate[hy000] [2002]

Hello all…

I have an existing application I am porting to the devildoc environment. It uses ‘localhost’ as the hostname for the dbo connections.

When I attempt to run the application I get the SQLSTATE[HY000] [2002] error.

If I run mysql from the ./shell command line without a hostname, I get the same error. I have tried mysql from specifying a variety of hostname with the results as follows:
localhost - failure
127.0.0.1 - success
container hostname - success
container IP - success

However, I only get failures from the application - when changing the hostname in the dbconn.

In MySQL, the username is configured with a % for the hostname. I have tried adding the IP address, subnet, localhost, etc but the results are always the same.

I have another application that is working fine in the same vhost (different directory).

See this documentation section 10. Best practice — Devilbox 1.0 documentation

If your project is inside the devilbox container, then the database connection should be 172.16.238.12

If your project is outside the container, in your host system, then it should be 127.0.0.1