Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 6 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


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.