No internet connection
  1. Home
  2. Technical Support

502 bad gatewaynginx/1.14.2 non-routed network behind proxy

By Alan Sill @alansill
    2023-10-20 20:24:10.237Zassigned to
    • @cghague

    I have a tinypilot in a private network where I can run DHCP but not DNS services and cannot route with NAT. Each device gets a unique IPv4 address and I can ssh in to the tinypilot (having set it up in a different network). I have the dreaded 502 Bad Gateway problem as so many before have posted, but can't seem to puzzle out a solution to connect to it.
    I tried setting up a proxy server on the intermediate node between the private and public networks, and was able to use the proxy methods described in the documentation and the help forum to update to the latest version, but am still getting the bad gateway message.

    Logs are at http://logs.tinypilotkvm.com/9H651HNP

    I think it's a routing problem. I tried with and without the proxy, and even tried deleting the default route and restarting networking. I can ping and ssh bidirectionaly between the intermediate node and the tinypilot, but nothing I do seems to fix the bad gateway problem. Assitance would be appreciated greatly!

    • 1 replies
    1. C

      Hi Alan, thanks for reaching out. I'm sorry to hear you're having trouble accessing your TinyPilot device.

      I've reviewed the logs, and it appears that TinyPilot isn't starting up correctly:

      tinypilot1 systemd[1]: tinypilot.service: Main process exited, code=exited, status=1/FAILURE
      

      In versions of TinyPilot Pro before 2.6.1, this will result in a generic HTTP 502 error message. The logs show that you're running TinyPilot Pro 2.5.3, so that would be the most likely explanation for the issue rather than a routing or network problem.

      This type of error is often the result of filesystem corruption, so we would typically recommend performing a factory reset. However, a factory reset can be quite a hassle. As your TinyPilot appears to be otherwise stable, you could optionally try a forced reinstallation of TinyPilot by connecting over SSH and running the following commands:

      if [[ -f /opt/tinypilot-updater/install ]]; then
        (sudo apt remove -y tinypilot || true) && \
          cd /opt/tinypilot-updater && \
          sudo ./install
      else
        /opt/tinypilot/quick-install
      fi
      

      A forced reinstallation can sometimes fix this error. However, if the issue is filesystem corruption, it may only be a temporary fix, so I recommend performing a full factory reset when convenient.