Matomo Analytics

Documentation

My application cannot connect to the MySQL server

If your application can't reach the MySQL/MariaDB server, work through the most common causes below. 1. Use 127.0.0.1, not localhost In your applicati...

If your application can't reach the MySQL/MariaDB server, work through the most common causes below.

1. Use 127.0.0.1, not localhost

In your application's configuration (for example Laravel's .env), set the database host to 127.0.0.1 instead of localhost. On Linux, localhost makes MySQL connect over a Unix socket, while 127.0.0.1 forces a normal TCP connection on port 3306, which is usually what you want.

2. Check your credentials

Confirm the database name, username and password match what you created in Ploi (Server > Databases). A mismatch is the most common cause of "access denied" errors.

3. Confirm the user may connect

Ploi-created users may connect from the server itself. If you connect from another server, you must also allow remote access — see How do I allow remote access to MySQL or MariaDB.

4. Make sure the database server is running

SSH into your server and check the service:

systemctl status mysql

If it isn't running, start it with systemctl start mysql and check the logs for why it stopped.

Dennis Smink

Written by Dennis Smink

Dennis brings over 13 years of hands-on experience in server management, specializing in optimizing web services for scalability and security.

Ready to dive in?
Start your free trial today.

Create an account and enjoy your 5-day free trial — no credit card required.

Start your free trial