# Error establishing a database connection

> "Error establishing a database connection" is one of the few messages a site genuinely displays. It says the programme could not reach the place where products, orders and customers are stored. The message is identical across four very different situations, and two of them have nothing to do with your credentials.

- Source canonique : [https://allaux.fr/en/problemes/erreur-de-connexion-a-la-base-de-donnees](https://allaux.fr/en/problemes/erreur-de-connexion-a-la-base-de-donnees)
- Langue : EN
- Dernière mise à jour : 2026-09-30

## Direct answer

> Open the file holding the credentials and compare them with the hosting panel: app/config/parameters.php on PrestaShop 1.7, 8 and 9, config/settings.inc.php on 1.6, wp-config.php on WordPress with DB_NAME, DB_USER, DB_PASSWORD and DB_HOST. If they match, test the connection from the command line with mysql: access denied and unreachable server are fixed in different places.

## One screen, four causes

- The connection credentials are wrong: the classic case after moving the site, a restore, or a password change on the host side.
- The database server is not answering: stopped, overloaded, or the address in the configuration is no longer right.
- The allowed number of simultaneous connections is reached: the site works intermittently, the error comes and goes on its own.
- A table is corrupted or the database is locked: the connection succeeds but an operation fails, which sometimes produces the same display.

## The intermittent error is the most revealing

When the message appears then disappears with no intervention, it is not the credentials. A wrong password fails every single time, without exception. An error that comes and goes points to a limit being reached: maximum simultaneous connections, database server memory, or a write quota.

The link with traffic is a good indicator. If the error appears at peak hours and vanishes overnight, the limit is reached by normal load: every visitor opens a connection, and connections never closed pile up. If it always appears at the same hour, a heavy scheduled task is the cause. If it appeared all at once and does not leave, it is a setting or a server incident.

## Check in this order

1. **Open the database administration tool** — If you can log in with the same credentials as the configuration file, they are correct and the problem is elsewhere. The quickest check available.
2. **Compare the database server address** — Many hosts do not use the local machine but a dedicated database server with its own address. A restore from another host keeps the old address, which now means nothing.
3. **Look at quota usage** — A full database goes read-only: the site displays but no order is recorded. The hosting panel shows the size used and the limit.
4. **Check table status** — An interruption during a write can leave a table inconsistent. The administration tool flags those tables and offers a repair.
5. **Read the database server log** — It states the reason for the refusal explicitly: too many connections, access denied, unknown database. The most reliable information of all.

## Never reinstall the CMS to clear this message

> A reinstall asks you to create a database, and therefore builds an empty site. Existing data is not lost while the database has not been overwritten — but it is once the installer completes. Faced with this message, the one thing never to do is launch an installer.

## Carry on with the right page

- **The database explained** — What a shop’s database actually holds. ([/glossaire/base-de-donnees](/glossaire/base-de-donnees))
- **Cleaning the database** — If the quota is reached, which tables take up the space. ([/wordpress-woocommerce/mise-a-jour/nettoyer-base-donnees](/wordpress-woocommerce/mise-a-jour/nettoyer-base-donnees))
- **Emergency support** — When the shop is down and orders no longer save. ([/services/depannage-urgent](/services/depannage-urgent))
- **The SQL query explained** — Why a database saturated with slow queries ends up refusing connections. ([/glossaire/requete-sql](/glossaire/requete-sql))

## FAQ

### The site shows the error but the admin works. Is that possible?

Yes, when the simultaneous connection limit is reached: the admin gets far fewer visits and still finds a free connection, while the public side no longer does.

### Is my data lost?

This message does not mean loss. It means the site could not reach the database. In the vast majority of cases the data is intact, and it is the connection that needs restoring.

### Where are the connection credentials stored?

In a configuration file at the site root, whose name depends on the CMS. Changing them needs file access, not back-office access.

### Why did the error appear with nobody touching the site?

A password change imposed by the host, a database server migration, a quota reached by normal data growth, or a host incident. None of these require any action from you.

### How long does recovery take?

When the cause is a credential or an address, it is short. When a table must be repaired or a database restored, it depends on its size and the quality of the last backup.
