• Hello everyone…I’m hoping someone out there can help. I’ve tried over and over to get this to work, but end with this same result. I have added the error message below. I’ve verified the database name, username, and password, but it still errors. Is there something else I’m missing? I’ve tried for three days. I really appreciate any help you can provide. Tazz

    Error establishing a database connection

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

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

    If you are unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress support forums.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator threadi

    (@threadi)

    I would recommend contacting your host’s support team to clarify whether the database access data is correct.

    To give yourself a little sanity check and make sure that you do indeed have the right hostname information, username, and password, you could connect manually to the database.

    It wouldn’t hurt to run a command line manual connection, like this…

    mysql -u database_username -p -h database_hostname database_name

    If you run that command using the same info that is in your wp-config.php, you should be able to see what the exact problem is from looking at the output of that command.

    • Did you already try to recover your site from some previous backup?
    • What did trigger that issue? Some update or other thing else? If so, describe to us in more detail about one in this thread.
    • Is your hosting plan shared ou a dedicated server?
    • Do you have FTP access?

    • This reply was modified 6 months, 2 weeks ago by Jorge Luiz. Reason: formated my text
    asgardalaska

    (@asgardalaska)

    May I suggest you try an edit to your wp-config.php file that has resolved the issue for other users when localhost isn’t resolving properly? Changing localhost to the loopback address at 127.0.0.1 can resolve the unable to connect to database issue in that instance. If you have write access to the files in your WordPress installation, you can try to change localhost to 127.0.0.1 as shown below and try your connection again.

    /** Database hostname */
    define( 'DB_HOST', '127.0.0.1:3306' );

    Hi Tazz, this error usually means WordPress cannot connect to your database, and while incorrect DB name, username, or password are common causes, there are a few other things to check. First, confirm that your DB_HOST is correct—it’s not always localhost; many hosts use something like 127.0.0.1 or a custom hostname from your hosting panel. Next, make sure your database user is actually assigned to the database with full privileges (this is often missed in cPanel setups). If you’re working locally, ensure your MySQL service is running. You can also test the connection with a simple PHP script to verify whether the issue is with WordPress or the database itself. If everything looks correct and it still fails, it could be a server-side issue, and contacting your hosting provider would be the next step.

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.