Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm creating custom error pages for my site. I want one that, if there is a generic error (invalid querystring, improper authentication, etc.) that will be shown. This is easy enough, problem is, what error code would this be? 404 is not found, 403 forbidden.

What code would this best fall under?

share|improve this question

2 Answers 2

up vote 5 down vote accepted

Return codes that will be useful to the client.

Bad authentication, 401. Bad request, 400. I'm a teapot, 418.

See RFC 2616 for more information.

share|improve this answer

There are a series of error codes defined in RFC 2616 for HTTP 1.1 that cover the scenarios you mentioned. For example, in the case of improper authentication, you should probably return code 401 (Unauthorized). In the case of an invalid query string, you might return code 400 (Bad Request).

Look at the RFC itself for the complete list along with some recommendations on when to return which error codes.

IETF: RFC 2616

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.