Database repeatedly disconnects

I’m having constant disconnects when trying to run my site locally. I can occasionally restart the site and connect briefly, but not long enough to do much.

Error reconnecting to the database

This means that the contact with the database server at localhost was lost. This could mean your host’s database server is down.

  • Are you sure the database server is running?
  • Are you sure the database server is not under particularly heavy load?

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.

With WP_DEBUG on, I get this:

Warning : mysqli_real_connect(): (HY000/2002): Connection refused in /Users/ … /app/public/wp-includes/class-wpdb.php on line 2019

Connection refused

I’ve tried the suggestion here: but the terminal returns “zsh: no matches found: /var/run/mysqld/mysqld.*

I deleted Local app and reinstalled.

Help please!

A couple of addendums:

  1. I was having this issue over a year ago. See post here: Database crashing suddenly

  2. I attempted to remove all plugins before restarting the site. Now I’m getting no database connection at all.

Hi @nickfindley

We would be happy to assist with your Local troubleshooting! Could you provide some more details to help us take a further look?

  • What is your OS?

  • What version of Local are you on?

  • Please attach a copy of your Local Logs

Keep us posted and we’d be happy to help further!


I’m on MacOS 13.4.1 and Local 7.0.2+6395.

Logs attached. (43.9 KB)

Hi @Nick-B just checking in to see if any progress has been made. Thanks!

Hi @nickfindley

Sorry for the delay, thank you for your patience. I have some clarifying questions.

Is this a new issue? As in, was Local working fine previously and then this cropped up after an update or change? Or has the issue always been present?

Are you running other developer applications simultaneously? Apps like MAMP, XAMPP, or Docker for example.

No worries!

I can’t recall exactly when the issue cropped up. But the issue began before I upgraded macOS, so it’s been an issue on either of the most recent two versions. I regularly update Local, but I can’t remember if I’ve had to update since the issue began. I’ve used Local without problems for almost as long as it’s been around.

I’m Local-only. To the best of my knowledge, no other dev tools are on my machine.

Is this happening for a single site? Or any site you try with?

Does changing your Router Mode make any difference?

What about security applications? Do you have any extra antivirus, firewall, etc running? Sometimes we’ve seen where a Local update might “reset” a block or limitation.

I may have narrowed it down to the WP Migrate plugin, though other sites seem to work fine with the plugin installed. But every time I try to use the plugin on one site in particular, I get the database crash.

I’m not using any aftermarket security software. I tried changing the router mode and didn’t have any success. If you think I need to take this to the WP Migrate support channels, I can do that. Thanks!

Hi @nickfindley

That’s interesting! I can also share some feedback with the WP Migrate team if this is indeed the issue as we work closely together.

It’s possible that WP Migrate isn’t playing well with another plugin. I’m not sure how you narrowed it down, but if you wanted to be thorough you could disable all of the plugins on the site, and then enable them one at a time to see which one causes the issue to resurface. If WP Migrate doesn’t cause the issue with all the other plugins disabled and the theme changed, then it may not be the sole culprit.

I had the issue with no other plugins but WP Migrate active. I then tried to go to the plugin settings and the database crashed. I haven’t modified the WP Migrate plugin, and I have the latest version of WP Migrate as well as all other plugins.

I need to try switching themes when I’m back at my dev machine to see if that solves anything.

Thank you for the update @nickfindley! Could you share an updated Local Log here? I’ll share some notes with the team, including our friends at Delicious Brains to see if there are any other thoughts as to how this could be contributing.

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