This Q&A covers the “Error establishing database connection” that can appear when your WordPress database reaches its storage limit. You’ll see where to check your wp-config.php settings, how to view database usage in your hosting panel, and methods to free up space or boost your database quota. Follow these steps to get your site back online quickly.
when I try to login it says "error establishing database connection"
The "Error establishing a database connection" message means WordPress can't connect to your database. Often, this happens when the database credentials in your wp-config.php file are wrong, the database server is down, or there's an issue with the database itself. Here are some steps to troubleshoot:
wp-config.php FileYour wp-config.php file holds the info WordPress uses to connect to the database. Access it via FTP or your host’s file manager in the root of your WordPress install.
wp-content, wp-admin, and wp-includes.define('DB_NAME', 'your_db_name'); — check that 'your_db_name' matches your actual database name.define('DB_USER', 'your_db_user'); — confirm the database username.define('DB_PASSWORD', 'your_db_password'); — double-check the password.define('DB_HOST', 'localhost'); — most hosts use localhost, but yours might differ.wp-config.phpContact your hosting support to ask if the database server is running properly. They can spot any outages or errors on their end.
WordPress offers a repair tool. Add this line to wp-config.php, above /* That’s all, stop editing! Happy publishing. */:
define('WP_ALLOW_REPAIR', true);
Then visit:
http://yourdomain.com/wp-admin/maint/repair.php
Choose “Repair Database” or “Repair and Optimize Database.” After repairing, remove the WP_ALLOW_REPAIR line for security.
DB_HOST ValueIf localhost isn’t correct, consult your host’s docs or support for the right database host address.
A faulty plugin can sometimes block connections. To disable all plugins:
wp-content.plugins folder to plugins_disabled.could the error be that my database is full
Yes, a full database might trigger the "Error establishing a database connection" message. When your database hits its storage limit, it can no longer accept new data or handle connections. Here’s why and how to check:
WP Assistant is a free tool created by Atiba Software, a WordPress design and development company located in Nashville, TN. If you need more personalized WordPress assistance let us know, and we’ll get back to you ASAP!