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
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.
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. Then enter the new one in wp-config.php.
DB_HOST is set to something other than localhostCheck
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.
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 databaseCheck
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 usageRelated guides
Need more help?
Email [email protected] or call 08-519 70 666.