---
title: "My application cannot connect to the MySQL server"
url: "https://ploi.io/documentation/database/my-application-cannot-connect-to-the-mysql-server"
published: "2018-08-01"
last_updated: "2026-06-15"
---

# 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 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 &gt; 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](https://ploi.io/documentation/database/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.