← Back to Forum
1
Troubleshooting
LocaltoNet 502 Bad Gateway while localhost still works
This popped up today on a little local app the kids and I use, and I'm trying to figure out where to look first before I start changing random things. The site still loads normally on http://localhost, but the LocaltoNet public URL now gives a 502 every time, and I haven't touched the router or firewall.
When this happens, is it usually something simple like the app binding to 127.0.0.1 instead of 0.0.0.0, the tunnel pointing at the wrong local port, or the app/server rejecting proxied requests or host headers? If anyone has a practical checklist for what to verify on the LocaltoNet side and on the Node/PHP server side, that would really help.
Comments (3)
One thing I'd add to the checklist is to try the exact LAN-style target yourself, not just
localhost, sohttp://127.0.0.1:portand if applicablehttp://your-machine-ip:port. I've had a small server stay perfectly fine onlocalhostbut fail once the request path changed slightly through a tunnel, especially when the app was being picky about theHostheader or trusted proxy settings.Check the LocaltoNet client config first and make sure the tunnel is still forwarding to the actual port your app is on, because 502 from these tools is very often just "backend not where I was told it would be," which is a fun little gift after a restart. I've had Node switch from one port to another because an env var changed or the old port was occupied, localhost still looked fine because I opened the new one in the browser, meanwhile the tunnel kept dutifully aiming at yesterday's port.
Yeah, I'd check what the app thinks the incoming host is before changing anything else. I've seen a tunnel hit the right local service just fine, but the app kicked it back because
APP_URL, allowed hosts, CSRF origin, or a reverse proxy trust setting no longer matched the public URL, so the tunnel surfaces it as a 502 and it looks more mysterious than it is.Please log in to post a comment.