Troubleshooting 502 errors

Does anyone have any insight into how to debug 502 errors being returned when the backend being proxied is not have any errors or issues? Any help trying in troubleshooting would be appreciated.

My go-to for troubleshooting these is two-pronged:

  1. Enable errors logging in the Caddyfile on the site that is proxying to the backend
  2. Run curl -IL [host] from the computer running Caddy at the backend host

The former might give some info on exactly why Caddy isn’t able to communicate with the backend, and the latter should give you an idea exactly how the backend is responding to a HTTP request from Caddy.

1 Like

And that second one (using curl) is especially important for eliminating the browser cache in testing :wink:

Might also want to enable the process log (-log flag) because some errors generated by the Go standard library don’t make it into the request log – instead they get logged directly right inside the standard lib.

1 Like

Thanks for the additional info. Looks like I’m getting a

07/Apr/2018:16:12:59 +0000 [ERROR 502 /] context canceled

I don’t believe the host is down at all. Any idea how I fix that?

That usually happens when a client closes the connection, not a big deal in that case. :slight_smile:

1 Like

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