#1 Data Analytics Program in India
₹2,499₹1,499Enroll Now
5 min read
•Question 2 of 28easy

What are HTTP Status Codes?

Understanding HTTP response status codes.

What You'll Learn

  • Status code categories
  • Common status codes
  • When to use each

Status Code Categories

RangeCategory
1xxInformational
2xxSuccess
3xxRedirection
4xxClient Error
5xxServer Error

Common Status Codes

Success (2xx)

  • 200 OK - Request succeeded
  • 201 Created - Resource created
  • 204 No Content - Success, no body

Client Errors (4xx)

  • 400 Bad Request - Invalid syntax
  • 401 Unauthorized - Authentication required
  • 403 Forbidden - No permission
  • 404 Not Found - Resource doesn't exist
  • 422 Unprocessable Entity - Validation failed

Server Errors (5xx)

  • 500 Internal Server Error - Generic server error
  • 502 Bad Gateway - Invalid upstream response
  • 503 Service Unavailable - Server overloaded

Example Usage

code.jsJavaScript
// Express.js examples
res.status(200).json({ data: users });
res.status(201).json({ id: newUser.id });
res.status(404).json({ error: 'User not found' });
res.status(500).json({ error: 'Internal server error' });