---
title: "My website can’t connect to the database"
url: "https://inleed.com/helpcenter/cant-connect-to-database"
language: "en"
updated: "2026-11-06"
category: "Web hosting"
type: "felsokning"
---

# My website can’t connect to the database

Your website shows “Error establishing a database connection” when it can’t reach its database. Work through the causes from the top.

## Common causes

### 1. You’ve changed the database user’s password

**Check:** Did you change the password recently? Then `wp-config.php` still has the old one.

**What to do:** Enter the new password in `wp-config.php`.

### 2. You don’t remember the database password

**Check:** The password is only shown when the database user is created. You can’t see it afterwards.

**What to do:** Change the password under **Databases › Manage Users** in [DirectAdmin](https://inleed.com/helpcenter/log-in-to-directadmin). Then enter the new one in `wp-config.php`.

### 3. `DB_HOST` is set to something other than `localhost`

**Check:** Does `DB_HOST` in `wp-config.php` say something other than `localhost`?

**What to do:** Change `DB_HOST` to `localhost`. The database is on the same server as the website.

### 4. You’re connecting from another computer or service

**Check:** Are you trying to reach the database from your own computer or an outside service? Only the server itself may connect until you allow more.

**What to do:** Add your IP address under **Manage Users › Allow access from › Add Host**.

[Allow remote connections to your database](https://inleed.com/helpcenter/allow-remote-database-access)

### 5. The error comes and goes

**Check:** Does the website work sometimes and fail at other times? Your hosting may be hitting its resource limits.

**What to do:** Check the resource usage to see whether the website reaches the limits.

[Check your hosting resource usage](https://inleed.com/helpcenter/check-resource-usage)

## Related guides

- [WordPress shows a critical error or a blank page](https://inleed.com/helpcenter/wordpress-critical-error)
- [View your website’s error log](https://inleed.com/helpcenter/view-error-log)
- [Allow remote connections to your database](https://inleed.com/helpcenter/allow-remote-database-access)
- [Create a database and a database user](https://inleed.com/helpcenter/create-database)
