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.
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
-
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.
-
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.
-
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.
-
Check table status
An interruption during a write can leave a table inconsistent. The administration tool flags those tables and offers a repair.
-
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.
Carry on with the right page
-
The database explained
What a shop’s database actually holds.
-
Cleaning the database
If the quota is reached, which tables take up the space.
-
Emergency support
When the shop is down and orders no longer save.
-
The SQL query explained
Why a database saturated with slow queries ends up refusing connections.
Describe your need in one minute
A few targeted questions so I can reply with an estimate rather than another questionnaire.