# WordPress says "Error establishing a database connection"

UrbeStack sysadmin note about MariaDB. Last updated 30 Nov 2026.

WordPress shows `Error establishing a database connection` on every page. MariaDB is down or the database user or password in `wp-config.php` differs from what MariaDB has, and two commands show which.

## Symptoms

Every page of the site shows `Error establishing a database connection`.

## Cause

WordPress could not connect to MariaDB using `DB_NAME`, `DB_USER`, `DB_PASSWORD` and `DB_HOST` from `wp-config.php`.

MariaDB may be down. The database user or password in `wp-config.php` may also differ from what MariaDB has, as can happen after you copy a site from another server.

## Resolution

Try connecting with the values from `wp-config.php`.

```
mariadb -u example_wp -p example_wp
```

If the database user or password is wrong, the command prints this error.

```output
ERROR 1045 (28000): Access denied for user 'example_wp'@'localhost' (using password: YES)
```

If MariaDB is down, the command prints this error on AlmaLinux.

```output
ERROR 2002 (HY000): Can't connect to local server through socket '/var/lib/mysql/mysql.sock' (2)
```

If MariaDB is down, check its state and start it.

```
urbestack-service-list --name mariadb
urbestack-service-restart --name mariadb
```

If the password is wrong, list the customer's database users and their grants.

```
urbestack-database-user-list --owner USER
```

Set a new password for the database user. The command reads the password from standard input.

```
urbestack-database-user-set --name example_wp --password-stdin
```

Put the same password in `DB_PASSWORD` in `wp-config.php`. The value of `DB_HOST` is `localhost`.

Run the connection command again with the values from `wp-config.php` to check that it connects. If it still prints one of the errors above, follow the steps for that error.

If the problem persists after you follow this note, you can [open a support ticket](https://support.urbestack.com/new?type=support). Including the output of the commands you ran helps support diagnose the problem.
