Error establishing a database connection. How to fix it?

Hi Everyone,

I’ve been using Local for a while now, I had created my entire website on it and I was going to launch it soon but I’ve now been getting this error when I try to view it:

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 you have typed the correct hostname?
  • Are you sure the database server is running?

I know it’s been talked about it on here, but I don’t know how to fix it. The wp-content.php doesn’t seem to have any problems. I tried to upload the zip folder of my website on local but it says that it cannot upload the sql file. I cannot log in Adminer because it says that the credentials are wrong. when I stop the site, I get this:

Error: Error: mysqldump exited with non-zero exit code.
at SiteDatabaseService. (/Applications/
at ()
at _0x5372ab (/Applications/
at processTicksAndRejections (internal/process/task_queues.js:85:5)

What should I do?

Thanks a lot,


Can anyone help? I’m going crazy trying to figure out what’s going on

Hello Daniele,
I hope you found a solution for your issue. I find mine but it far from resolving the issue:
I imported an “export” of the site I made few days back and use the typed the password myself to be sure that it was the right one, and it worked

How the problem happened :
-My mac shut down unexpectedly
-When i restarted it, and local, it asked me for my Wordpress Login & Password
-I put the password registered by my google account
–> and then had the issue to not be able to access my website with local

    Uh-oh! Local ran into an issue while exporting this site's database to the site's 'app/sql' directory.
Error: Error: mysqldump exited with non-zero exit code.
    at SiteDatabaseService.<anonymous> (/Applications/
    at (<anonymous>)
    at _0x234e99 (/Applications/
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:85:5)

I’ll keep looking to find a way to resolve this for the site that is in error.

Good luck !

I have the same MySQL non-zero exit message when closing my sites also. Local continues to open and seems to work properly except for closing. I switched off AV, reinstalled, checked codes. Did you ever find an answer? Did it adversely effect anything?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.