Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What status code should I return for a connection error?

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?

like image 599
Derek Stobbe Avatar asked Apr 23 '13 03:04

Derek Stobbe


People also ask

What is a 309 status code?

Status codes 309 through 399 are currently unassigned.

What is HTTP status code1?

We tend to get -1 status codes when there are network issues or connection problems, so we display the user a network problems page in those cases.

What is the difference between 200 and 201 status code?

A 200-level response means that everything is working exactly as it should. 200: “Everything is OK.” This is the code that is delivered when a web page or resource acts exactly the way it's expected to. 201: “Created.” The server has fulfilled the browser's request, and as a result, has created a new resource.

What is a 299 status code?

HTTP response codes 200 – 299 are bearers of good news: the request has been accepted, a new request has been created, or a certain problem was solved.


1 Answers

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.

like image 109
PaulProgrammer Avatar answered Oct 12 '22 12:10

PaulProgrammer