502 error - 4 days work lost in localwp

What issue or error are you experiencing?

After a very productive holiday weekend, I used the export function of LocalWP to back up the site. I also used the “Cloud Backups” plugin to backup the site to Google Drive. What I did not do was use UpdraftPlus to export a backup that could be used independently of LocalWP.

I would advise others reading this to ALWAYS DO THAT FIRST. ALWAYS make a backup of your site that is independent of LocalWP (use UpdraftPlus or something similar). You cannot trust LocalWP to not choke and lose all of your work.

After making my 2 backups, I took a well deserved break for about an hour. When I returned, I opened LocalWP, started the site and clicked the “Open site button”. But, instead of opening the site where I left off, it showed me a 502 error.

The error said to restart the site.

I did and this fixed nothing. I closed all applications and restarted my PC. I restarted LocalWP and I got the same error.

I did as the error instructed and looked at the log files and found errors like this (which mean nothing to me)…

2024/05/27 22:04:07 [error] 16324#21304: *3 connect() failed (10061: No connection could be made because the target machine actively refused it) while connecting to upstream, client: ::1, server: prod2dev0523242142.wfpc, request: “GET / HTTP/1.1”, upstream: “http://127.0.0.1:10005/”, host: “prod2dev0523242142.wfpc”

2024/05/27 22:04:10 [error] 16324#21304: *6 connect() failed (10061: No connection could be made because the target machine actively refused it) while connecting to upstream, client: ::1, server: prod2dev0523242142.wfpc, request: “GET /favicon.ico HTTP/1.1”, upstream: “http://127.0.0.1:10005/favicon.ico”, host: “prod2dev0523242142.wfpc”, referrer: “http://prod2dev0523242142.wfpc/

2024/05/27 22:04:49 [error] 27236#16836: *1 connect() failed (10061: No connection could be made because the target machine actively refused it) while connecting to upstream, client: ::1, server: prod2dev0523242142.wfpc, request: “GET / HTTP/1.1”, upstream: “http://127.0.0.1:10005/”, host: “prod2dev0523242142.wfpc”

2024/05/27 22:04:52 [error] 27236#16836: *1 connect() failed (10061: No connection could be made because the target machine actively refused it) while connecting to upstream, client: ::1, server: prod2dev0523242142.wfpc, request: “GET /favicon.ico HTTP/1.1”, upstream: “http://127.0.0.1:10005/favicon.ico”, host: “prod2dev0523242142.wfpc”, referrer: “http://prod2dev0523242142.wfpc/

2024/05/27 22:14:57 [error] 2392#6868: *1 connect() failed (10061: No connection could be made because the target machine actively refused it) while connecting to upstream, client: ::1, server: prod2dev0523242142.wfpc, request: “GET / HTTP/1.1”, upstream: “http://127.0.0.1:10005/”, host: “prod2dev0523242142.wfpc”

2024/05/27 22:15:00 [error] 2392#6868: *3 connect() failed (10061: No connection could be made because the target machine actively refused it) while connecting to upstream, client: ::1, server: prod2dev0523242142.wfpc, request: “GET /favicon.ico HTTP/1.1”, upstream: “http://127.0.0.1:10005/favicon.ico”, host: “prod2dev0523242142.wfpc”, referrer: “http://prod2dev0523242142.wfpc/

I used netstat to look for the server port (as this seemed to be a server error of some type) and I noticed that the server port (10005) was not in use. Does this mean that the Apache server is no longer working on that site within LocalWP?

I have since (since I have had some 17 hours to contemplate losing my client because of this) tried everything that I could think of.

I made new site and manually copied over the files from the old site. This fixed nothing.

I created a staging site on a real server, copied all public files to it, imported the sql file and the work that I had done using Elementor is not there (but two files used for shortcodes that I created are). Site still does not work.

I tried cloning the site. this only cloned the problem.

I tried making a new clean WP site in LocalWP. this worked, but it doesn’t help me get my 4 days of work back or create a working copy of the site I was working on.

This problem seemed to happen at the same time that LocalWP’s community site went down due to non-payment of some hosting fees. Is LocalWP connected to something online that would be affected by the forum suspension that could have corrupted my site or the backups of the site? It is very odd that these two things happened at the same time.

This is horrible beyond words. I cannot fathom getting people to trust me with their important development projects, only to have no way to help them if they have an issue.

I will be moving future development to InstaWP.com, but I really need to recover the 4 days of work that I did on the site over the holiday weekend, if it is possible to do so.


What steps can be taken to replicate the issue? Feel free to include screenshots, videos, etc

I am unsure of how you would (or why you would) intentionally break a LocalWP site.


System Details

  • Local Version:
    Version 9.0.3+6684

  • Operating System (OS) and OS version:
    |Edition|Windows 10 Pro|
    |—|—|
    |Version|22H2|
    |Installed on|‎11/‎29/‎2023|
    |OS build|19045.4412|
    |Experience|Windows Feature Experience Pack 1000.19056.1000.0|


Local Logs

Attach your Local Logs here (Help Doc - Retrieving Local’s Log)

Here are the 3 log files that were in roaming/local on my Windows 10 PC…
local-lightning-verbose - three log files.zip (223.0 KB)

access.log (1.5 MB)
error.log (9.8 KB)
site-error.log (6.9 KB)

error-shortened.log (390.1 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.

As far as I can determine, this is as close to the exact moment that things broke that I can get…

[28-May-2024 19:50:03 UTC] PHP Warning: mysqli_real_connect(): (HY000/2002): No connection could be made because the target machine actively refused it in H:\local-sites\prod2dev0523242142\app\public\wp-includes\class-wpdb.php on line 1987

Now the questions are as follows…

  • Is the db not spinning up for some reason?
  • What launches the db and how do we test that it is working?
  • If it is running, what caused the db to stop accepting connections?
  • Was it a problem with the port number?
  • Was it a problem with the username/password?
  • Where is the username/password set?
  • Where is the port number set for the db?

These things should be accessible via the LocalWP GUI. Seriously…why aren’t they?

Since LocalWP is basically advertising for WP Engine, I’d think it would be wise to make it good advertising. Crappy ads win RAZZIEs but they don’t win clients.

Getting closer - although I’d pay for a dev environment that was maintained with actual support…

{“level”:“error”,“message”:“Error setting up MySQL user”,“service”:{},“serviceBinVersion”:{},“stack”:“Error: Command failed: %%userDataPath%%\lightning-services\mariadb-10.4.32+0\bin\win32\bin\mysql.exe --password= -e ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘root’;\nERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: NO)\r\n\n at ChildProcess.exithandler (node:child_process:422:12)\n at ChildProcess.emit (node:events:517:28)\n at ChildProcess.emit (node:domain:489:12)\n at maybeClose (node:internal/child_process:1098:16)\n at ChildProcess._handle.onexit (node:internal/child_process:303:5)”,“thread”:“main”,“timestamp”:“2024-05-29T01:38:57.786Z”}

I can connect with AdminerEvo - so why doesn’t the site connect?

Where is the ini or whatever that holds the username, password, database name, host and port for the database? We wouldn’t need to ask if they were in the GUI.

@jim_hubbard I’m sorry for the bad experience here.

This problem seemed to happen at the same time that LocalWP’s community site went down due to non-payment of some hosting fees. Is LocalWP connected to something online that would be affected by the forum suspension that could have corrupted my site or the backups of the site?

The Local app is not dependent on the forums for local site development or backups. (The only connection it has to the forums is to display links to the forum and a list of forum posts on Local’s help page.)

I really need to recover the 4 days of work that I did on the site over the holiday weekend, if it is possible to do so.

As Local fails to start your site to let you restore a Cloud Backup there, you can try restoring the backups you made manually with restic:

(You’ll need the “manual recovery password” from this page: Local Hub )

As to why the current site is not starting, the logs show a combination of Apache failing to start due to a configuration issue:

{"class":"Process","level":"warn","message":"AH00526: Syntax error on line 28 of C:/Users/jimhu/AppData/Roaming/Local/run/yOj9WQVNW/conf/apache/site.conf:","process":"httpd","thread":"main","timestamp":"2024-05-28T18:49:58.166Z"}

And MySQL failing to connect due to a user/password or missing user issue:

{"class":"Process","level":"warn","message":"2024-05-28 14:50:00 12 [Warning] Access denied for user 'root'@'localhost' (using password: NO)","process":"mariadb","thread":"main","timestamp":"2024-05-28T18:50:00.797Z"}
{"class":"Process","level":"warn","message":"2024-05-28 14:50:00 13 [Warning] Access denied for user 'root'@'localhost' (using password: NO)","process":"mariadb","thread":"main","timestamp":"2024-05-28T18:50:00.850Z"}
{"level":"error","message":"Error setting up MySQL user","service":{},"serviceBinVersion":{},"stack":"Error: Command failed: %%userDataPath%%\\lightning-services\\mariadb-10.4.32+0\\bin\\win32\\bin\\mysql.exe --password= -e ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';\nERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)\r\n\n    at ChildProcess.exithandler (node:child_process:422:12)\n    at ChildProcess.emit (node:events:517:28)\n    at ChildProcess.emit (node:domain:489:12)\n    at maybeClose (node:internal/child_process:1098:16)\n    at ChildProcess._handle.onexit (node:internal/child_process:303:5)","thread":"main","timestamp":"2024-05-28T18:50:00.854Z"}

I’m sorry that you encountered this — it’s not something I’ve seen following backup creation or a Local upgrade before.

To work around the Apache error, you could try temporarily switching the site to use nginx by toggling “web server” from Apache to nginx.

Since you can now connect to the MySQL database with AdminerEvo, you could try confirming that the database connection details in your wp-config.php file are correct. You’ll find that after clicking “go to site folder” and navigating to app/public.

Is the db not spinning up for some reason?

That does not now seem to be the case given that you can access it with AdminerEvo.

What launches the db and how do we test that it is working?

Local launches the database process. It’s working when you can connect to it with AdminerEvo, with a database client using the information on your site’s database tab, or with WordPress.

Where is the username/password set?

Local configures a MySQL/MariaDB user when setting up the service. The username/password is root/root. It’s set directly via mysqld.

Where is the port number set for the db?

The port number is displayed on the database tab (on Windows; on macOS/Linux sockets are used instead of ports). The port number is configured in Local’s sites.json file. On Windows you can access this like so:

  1. Open the Windows File Explorer.
  2. Make sure you have enabled “show hidden items”.
  3. Browse to This PC → [your hard drive] → Users → [your username] → AppData → Roaming → Local.
  4. You’ll find sites.json there. It’s worth taking a backup of this if you intend to modify it.

If this information doesn’t help to get the existing site running, I recommend starting a new site using the manual backup retrieved with restic.

2 Likes

Thanks for the pointers. I decided to just rewrite the code. It would have been faster than trying to figure this out and that should have been my first move.