What status code should I return for a connection error?

502 Bad Gateway, since you're acting as a proxy server.

The HyperText Transfer Protocol (HTTP) 502 Bad Gateway server error response code indicates that the server, while acting as a gateway or proxy, received an invalid response from the upstream server.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502


503 Service Unavailable seems like an appropriate choice. The 4xx codes are meant to indicate the client did something wrong. In the case you specify, it's a service error.