What status code should I return for a connection error?

http, http-headers

Solution

`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.

Problem

I'm writing a service that returns data about another request to the consumer (for example, retrieving the un-shortened URL from a bitly or t.co address). In most situations, I can return a status code to mirror the code I received from the server, but what status code is most appropriate when my service is unable to connect to the requested URL (if it doesn't exist, for example)? I was thinking `400 Bad Request` or `408 Request Timeout`, but is there a best practice here?

Original source