I wanted to share a bug I encountered and the workaround I found, in case others are experiencing the same issue.
Environment
macOS 14.7.1 (Sonoma)
MacBook Pro (Apple Silicon, arm64)
Local Version: 10.1.0+6912
What happened
All my Local sites suddenly stopped working overnight. The browser showed:
“404 - Site Not Found”
“ERR_CONNECTION_REFUSED”
I had not changed anything. It worked fine the day before.
Root Cause I Found
After hours of investigation, I discovered that Local’s router nginx could not start because macOS had automatically deleted a temporary directory that Local depends on:
When I tested the nginx config manually, I got this error:
nginx: [alert] could not open error log file: open() "/var/folders/.../T/local-lightning-nginx/compiled/logs/error.log" failed (2: No such file or directory)
nginx: [emerg] open() "/var/folders/.../T/local-lightning-nginx/compiled/logs/nginx.pid" failed (2: No such file or directory)
nginx: configuration file test failed
macOS periodically clears folders under /var/folders/ — especially after system updates or maintenance. Local’s router nginx depends on this temporary directory, but Local does not automatically recreate it when it is missing.
Temporary Workaround
I can get sites working again by manually creating the directory and starting the router nginx via the command line. However, every time I stop and restart a site in Local, the router nginx stops again and I have to repeat the process.
Expected Fix
Local should automatically check if the required temporary directory exists at startup and recreate it if missing, so the router nginx can always start successfully.
Has anyone else experienced this? Is there a permanent fix?
Hi, thank you for your response. Please find the Local log file attached. I have attached local-lightning.log (the most recent one) and local-lightning-verbose.log. Please let me know if you need any additional information.
Are you running other developer applications simultaneously @taka? Or do you have any additional security in place? It seems like from the log that the database has struggled to make connections and there have been some other router blocks.
Thanks for your report and the extra information, @taka.
Local does not use the /var/folders path by default for error logs. You’re probably seeing this path because you were running nginx manually during testing without passing the path to Local’s runtime folder.
When Local runs nginx, it passes the -p prefix to its own runtime path outside of /var/folders. It also creates logs and temp folders outside of /vars/folders each time it starts nginx. If you happen to run nginx manually without those paths, though, it will default to its compile-time path under /var/folders/.
If you see the ERR_CONNECTION_REFUSED or 404 - Site Not Found again, please share Local’s router log with us just after you experience the issue. (Local → Help → Reveal Local’s router log.) That might give us some extra info around why the router fails to start.
I am running the following applications simultaneously:
Zoom
Figma
Google Chrome
Chatwork
Adobe Creative Cloud
I do not have any additional security software installed (no antivirus or firewall applications other than the default macOS firewall).
I also remembered that I launched MAMP once before this issue started. I closed it, but I am not sure if any MAMP processes or configurations are still running in the background and conflicting with Local’s router.
Regarding the database connection issues mentioned in the log — I believe those occurred because I was repeatedly stopping and restarting Local while trying to troubleshoot the issue.
The core problem I am experiencing is that Local’s router nginx fails to start after macOS clears the temporary directory /var/folders/.../T/local-lightning-nginx/. Every time I stop and restart a site in Local, the router nginx stops and I have to manually restart it via the command line.
Please let me know if you need any additional information.
When I click “Open Site” in Local, it redirects me to http://localhost/ instead of the correct local URL. The browser shows 500 Internal Server Error - nginx/1.26.1. Even when I manually type the correct local URL in the browser, I get the same 500 error and the site does not display.
From the nginx error log, I can see the following error:
stat() failed (13: Permission denied)
nginx is running as root and nobody, which seems to be causing the permission issue.
After reviewing the router error log, I found two recurring issues:
connect() failed (61: Connection refused) — The router is trying to forward requests to port 10007, but the site’s nginx is actually running on a different port (e.g. 10020). It seems the router configuration is outdated and not reflecting the current port.
stat() failed (13: Permission denied) — The router nginx was started manually with sudo, so it is running as root. As a result, it cannot access files owned by my user account, causing permission errors on the error pages.
Could you please advise on how to fix these issues properly?
Can you share your full Local Log with us @taka? There are some different ways to access and share Local Logs. For us to be able to troubleshoot thoroughly, please click the Download Local Logs button from the Support tab in Local (Question mark on the left hand side of your Local app, and then scroll down). This will generate a zip archive that contains the Local log along with some other diagnostic information to help quickly zero in on any issues that Local is encountering.
What are you utilizing for Local’s Router Mode as well? Preferences>Advanced>Router Mode
Hi, thank you for your response. Please find the Local logs attached as requested.
Regarding the Router Mode, it is currently set to “localhost”.
Thank you for your continued support.
If you want Local to try connecting via a domain name like domain.local then you’ll need to change your Router Mode to site domains. It looks like from your Router Log that you had it set there previously, but both are running into permissions errors.
Have you tried checking/fixing permissions on the file and parent directories mentioned?
Is this a personal device of yours where the user also has admin privileges?
Thank you so much for your help! After changing the Router Mode to “site domains”, the sites are now displaying correctly. The issue has been resolved!
I believe the Router Mode may have been accidentally changed to “localhost” while I was troubleshooting via the terminal. That was likely the root cause of the issue.