No Database Connection for ANY site [Update: possible solution in comments]

Issue Summary

After updating to latest version to Local on a new computer (Mac M1 OSX 12) none of my sites are available and all showing the ’ Error establishing a database connection’ error. I am also unable to use Adminer. Downgrading to 6.1.8 did not solve the problem.

Troubleshooting Questions

This happens on ALL sites and Adminer

  • Are you able to create a new, plain WordPress site in Local and access it in a Browser?

Yes I am able to create a new site and access a new test site.

Replication

Launched site, click on the Open Site button. Get error message about database connection (see above).

Click on the database tab in local and click the admirer link. Adminer opens and displays login link with ‘Connection refused’ error.

System Details

  • Which version of Local is being used?
    6.1.8 But 6.3 just before

  • What Operating System (OS) and OS version is being used?
    OSX 12.2.1 M1

  • Attach the Local Log. See this Help Doc for instructions on how to do so:
    See:
    local-lightning.log (244.5 KB)

Security Reminder

Local does a pretty good job of scrubbing private info from the logs and the errors it produces, however there’s always the possibility that something private can come through. Because these are public forums, always review the screenshots you are sharing to make sure there isn’t private info like passwords being displayed.

Finding similar results and errors, just seemingly not as widespread as it may have been on my system. The ‘Fix’ seems to be importing the site again (Error establishing database connection after restart)

I’d like to add that this is NOT a fix. It’s a costly work-around. This just stole a few hours (between noticing of that error) until I have licenses and other elements updated to I can work with that site again where I left of previously.

Is there any hint in those logs that could provide a clue where this could be fixed from WITHIN the install? (WP CLI, mysql command, shell script?) Maybe it time for a repair installation script of sorts? That could fix the current installation (or dare I say checks all of them?)

After digging through the verbose version of the Local Log I found the first entry from today that showed that there was an error:

{“message”:“Electron Event activate”,“level”:“info”,“timestamp”:“2022-02-24T18:14:23.919Z”}
{“thread”:“main”,“class”:“SiteProcessManagerService”,“stack”:“Error: mysqldump exited with non-zero exit code.\n at SiteDatabaseService. (%%appPath%%/main/sites/database/SiteDatabaseService.js:1:2662)\n at Generator.next ()\n at s (%%appPath%%/main/sites/database/SiteDatabaseService.js:1:742)\n at runMicrotasks ()\n at processTicksAndRejections (internal/process/task_queues.js:93:5)”,“level”:“error”,“message”:“Unable to dump database.”,“timestamp”:“2022-02-24T18:27:39.441Z”}

After that we have a bunch of ‘Killing Process’ messages presumably shutting down the various components.

And then a message that a key already exist for a local site:
{“thread”:“main”,“class”:“X509CertService”,“level”:“debug”,“message”:“XXXXXX.local.key already exists. Skipping certificate creation.”,“timestamp”:“2022-02-24T18:27:40.708Z”}

This persists for all sites. The we start by killing nginx and updating the host services but seemingly not being able to connect to the db: mysql":{“database”:“local”,“user”:“root”,“password”:"[REDACTED]"},“ports”:{},“hostConnections”:null…

Thats the extend of my sleuthing, but hope your dev team has some ideas…
Hoping to hear back from you,
Sebastian

Ok I did some more digging and it seems that the site or any service is prevented from using mysql because it’s already running. So I tried to restart the service from within the site specific shell, but I couldn’t get it running due to the same error.

What I did notice is that it looks for a file in the ~/Library/Application Support/Local/run/[SITE ID]/mysql/

AND I saw that there was a LOCK file! I removed that file and restarted the site in Local. Voila! the site starts up again.

Now to my MAJOR REQUEST: Make a tool that goes through all sites and checks for lock files before starting up (if NOT running) and optionally remove them.

Hope this helps anyone else and now I can leave my obsessive brain to actually work on my project. :wink:

1 Like

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