Fix the Error Establishing a Database Connection | Sometimes when you surfing your website and then your website get an error and it mentions “Error Establishing a Database Connection”.

So, what you can do?

As a WordPress beginner, you should not be panic because this is not a serious problem. You can fix it with several methods. This is not warning your website under attack from the hacker. It just a problem come from your server.

Fix the Error Establishing a Database Connection in WordPress

So, how you can fix the error Error Establishing a Database Connection in WordPress?

Before we go details how to fix it, let we look where this problem comes from.

  1. wp-config file on your wordpress file got a little disturbing.
  2. Your server has a little problem for connection. Usually, it will be fine without doing anything.

There are two basic easy methods you can do.

Method #1 Fix your wp-config File

The main reasons why your database error connection is maybe a little thing in your wp-config file was changed. So, you need to make sure all of it correct.

This is content contains in wp-config file.

 define('DB_NAME', 'database-name');
define('DB_USER', 'database-username');
define('DB_PASSWORD', 'database-password');
define('DB_HOST', 'localhost'); 

If you choose the best hosting like FastComet, they will help you to fix it for free anytime. Just contact them and you take a rest. Usually, they will fix any problem in just 15-30 minutes.

Method #2 Repair WordPress

Many WordPress users do not know this trick how to repair their WordPress. This method is so easy because it can be done with just a few clicks.

Step 1

Access your cPanel and open file wp-config.php

Step 2

Add the code below

 define('WP_ALLOW_REPAIR', true); 

and paste it before ‘That’s all, stop editing! Happy blogging’ line wp-config.php

Step 3

Once you have done, visit your link like this You will see like as an image below.

Step 4

Click the button “Repair and Optimize Database” and wait a few minutes to be done.


In this topic, you have learned how to handle if your website shows the message “Error Establishing a Database Connection”. For us, you should not know all about this technical. You just focus on your blogging.

So, who can help you if you have a problem like this?

The answer is, just choose the right web hosting. Our recommendation for your blogging, business or e-commerce website, choose FastComet because of their support very excellent.

 1,768 total views,  2 views today

If you like this article, then please FOLLOW to our Google+ and Facebook. Do not forget to check our services page for empowering your WordPress. If you find this post outdated or error, please contact us to fix it.