• Today, randomly my WordPress site decided to be Up and Down several times. On the Wp-Admin page it says “Error Establishing a Database Connection” and sometimes a 504 Error also…

    Connected to BlueHost and they said they can’t find anything wrong with the connection. However I haven’t changed anything in my WordPress files to make this happen?

    Error establishing a database connection

    This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at localhost. This could mean your host’s database server is down.

    Are you sure you have the correct username and password?
    Are you sure that you have typed the correct hostname?
    Are you sure that the database server is running?

    If you’re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.

    Also every once in a while I do get to the WP dashboard so the password/username thing isn’t it

Viewing 3 replies - 16 through 18 (of 18 total)
  • Hi bro!
    To fix this problem try those fixes :

    1. Open wp-config.php, check line DB_USER, DB_PASSWORD, DB_HOST, DB_NAME. Make sure the values is same with mysql access.

    2. If you use Dedicated server or VPS hosting, try to restart your mysql server by typing :
    -service mysql restart
    or
    -service mysql start
    but if you use shared hosting, ignore this step!

    3. if all the previous fixes can not fix it, so it’s a server-side problem! it is not your error! so let the hosting company fix this error for you because it is their error!
    contact them or give them a day or so and they will solve this error and the problem will disappear automatically.
    you can also check this video for the error establishing database connection fixes

    For me the issue was DNS. I was using AWS RDS for database, ping responded ok, dig responded ok, I could telnet to it.
    Then I tried using PhpMyAdmin and it responded with

    
    mysqli_real_connect(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname

    Wordpress didn’t show this error, I couldn’t find it in any logs.

    I added RDS IP into /etc/hosts file and that solved the issue in WordPress.
    No idea why PHP had issue resolving RDS hostname.

    I have had this problem a number of times on different sites. When I go into my PHP all the data files contain no information and my host company has to install a backup. One of the sites I run for a client is an online learning program for students internationally. There is no way I can continue backing up every 5 minutes and not knowing why this crash happens is very frustrating. Any thoughts?

Viewing 3 replies - 16 through 18 (of 18 total)
  • The topic ‘Error Establishing a Database Connection’ is closed to new replies.