According to www.w3.org, a Web server should reply with status code 400 Bad Request if:

"The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications"

Does that mean only request that violates some HTTP spec?
Or does it include a request that my particular Web app thinks is broken?
When would you reply 400?

For example, if my Web app expects a query string to always include a "function=..." parameter, would you reply code 400 Bad Request or 403 Forbidden? (403 means that "The server understood the request, but is refusing to fulfill it.")

1 Answer 1


My interpretation of that header is that the HTTP specification was not followed properly and a required field is missing or bad data is provided. For example a header is missing or invalid characters are used in the request, etc.

Some malformed request exam-ple:

GET /images/logo.png HTTP/2 # there is no HTTP 2
POTT /images/logo.png HTTP/1.1 # POTT should be POST
Accept-Language  en-US # Missing colon after header name

Your example seems like a legitimate usage of that HTTP response code. However, I suspect this would be better handled in your application. If that parameter is missing you can serve up a much prettier and more through error message. You can also have the page report back to you about the error so you can investigate it if necessary.

  • +1 - Thanks I'm working on a site right now that has a bunch of these reported by webmaster tools and was wondering about them. I think a custom 404 page is preferable response from the server.
    – JMC
    Commented Jun 28, 2011 at 18:12
  • Why not a custom 400 page sometimes, and a custom 404 sometimes? (I just tested in my webapp and, on my computer, Chrome & Firefox shows the plain text message in the status 400 page)
    – KajMagnus
    Commented Jun 30, 2011 at 6:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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