🚦 Essential HTTP Status Codes You Should Know 🚦

Shivam GoswamiShivam Goswami
7 min read

On Day 4 of My DevOps Journey 🚀

A video just dropped on my YouTube feed about HTTP Status Codes 📺. Out of sheer curiosity 🤔, I watched it and found it super interesting! As a developer, you constantly encounter these status codes when making requests—like the infamous 404, the “lucky” 200 ✅, the redirect 302 🔄, and many others. So today, in this article, I’ll dive into what HTTP Status Codes are, explore their types, and highlight some of the most common ones you’ll likely face on production 🌐.

I followed two fantastic videos for this:

These videos are some of the best on YouTube 🎥 for learning about HTTP Status Codes—packed with information, super easy to follow, and engaging!

WHAT ARE HTTP STATUS CODES ?

HTTP Status Codes are like messages 📩 from a server (a computer) that tell you if your request was successful, or if something went wrong. Every time you try to access a website or an online resource, your computer sends a request to a server, and the server replies with a status code to let you know what happened. Think of it as a quick response note that says, “Got it!” or “Oops, something’s up!”

HTTP Status Codes are crucial for debugging production errors because they quickly indicate the type of issue.

By providing clear, immediate feedback, status codes help you pinpoint problems, track recurring issues, and collaborate efficiently with teams, leading to faster troubleshooting and minimal downtime.

1. 1xx (Informational) 🛠️

  • Indicates that the request has been received and the server is processing it.

2. 2xx (Success)

  • Indicates that the request was successfully processed by the server.

3. 3xx (Redirection) 🔄

  • Indicates that the client needs to take further action to complete the request, usually involving a URL redirect.

4. 4xx (Client Error) 🚫

  • Indicates that the client made an error in the request, such as incorrect data or invalid access.

5. 5xx (Server Error) 💥

  • Indicates that the server failed to process a valid request due to an error on its side.

SOME HTTP STATUS CODES

1. 200 OK ✅

  • Explanation: The request was successfully processed, and the server has returned the requested data.

  • Real-Life Example: You walk into a café ☕, order a coffee, and the barista serves it just as you asked. Everything went as expected.

  • Internet Example: When you visit a webpage and it loads correctly (like your favorite blog post), the server responds with a 200 OK status, meaning the request was successful and the data (page) is returned to you.

2. 201 Created 🎉

  • Explanation: The request was successful, and a new resource has been created as a result of the action.

  • Real-Life Example: You order a custom-made t-shirt 👕 at a store, and the shop creates it just for you. The order was successful, and a new item was created.

  • Internet Example: When you sign up for a new account on a website, like creating a new social media account, the server responds with 201 Created, meaning your account has been successfully created.

3. 204 No Content 🚫

  • Explanation: The request was successful, but there’s no content to return. It's commonly used for actions like submitting forms where no response content is needed.

  • Real-Life Example: You visit a website, and the page loads, but there’s nothing new to show you (like a "status update" page that’s empty).

  • Internet Example: After you update your profile on a website (such as changing your email address), the server returns 204 No Content, meaning the update was successful, but no new page or content needs to be sent back.

4. 301 Moved Permanently 🔗

  • Explanation: The resource has been permanently moved to a new URL, and the client should use the new URL for future requests.

  • Real-Life Example: Imagine a bookstore 📚 changing its location, and now, every time you search for its old address, you’re redirected to the new one.

  • Internet Example: If a website changes its URL or page location permanently (like a blog moving to a new domain), the server sends a 301 Moved Permanently status to redirect visitors to the new address.

5. 302 Found 🚦

  • Explanation: The requested resource is temporarily located at a different URL, and the client should follow the redirection for the time being.

  • Real-Life Example: A café temporarily closes for renovation 🛠️ and redirects all its customers to a nearby branch instead.

  • Internet Example: When you try to access a page that's temporarily moved (like a website undergoing maintenance), the server returns 302 Found to redirect you to a temporary page or URL.

6. 400 Bad Request ❌

  • Explanation: The server couldn’t understand the request due to malformed syntax or invalid data.

  • Real-Life Example: You try to order a coffee at a café ☕ but forget to specify your choice (e.g., “latte” or “espresso”). The barista can’t process your request because it’s incomplete.

  • Internet Example: When you enter an invalid URL, or submit a form with missing or incorrect information (like an empty search query), the server responds with 400 Bad Request, indicating it can't understand your request.

7. 401 Unauthorized 🔐

  • Explanation: The request requires authentication (usually a login or valid credentials), and the client has not provided it.

  • Real-Life Example: You try to enter a members-only club 🏢, but the bouncer tells you to show your membership card before you can get in.

  • Internet Example: When you try to access a private page or service (like an account dashboard) without being logged in, the server responds with 401 Unauthorized, prompting you to authenticate before proceeding.

8. 403 Forbidden 🚫

  • Explanation: The server understands the request but refuses to authorize it. The client has no permission to access the resource.

  • Real-Life Example: You have the right membership card, but you try to enter the VIP lounge 🛋️ in a club, and the bouncer says, "No entry here."

  • Internet Example: If you try to access a page or resource (like an admin panel) on a website that you don’t have permission to view, the server will respond with 403 Forbidden, indicating you're not allowed to access it.

9. 404 Not Found 🔍

  • Explanation: The server could not find the requested resource. The URL might be incorrect or the resource may no longer exist.

  • Real-Life Example: You visit a library 📚 looking for a book, but the librarian tells you it’s not available in their collection because it’s missing.

  • Internet Example: When you type an incorrect URL or click on a broken link (e.g., trying to access a page that no longer exists), the server responds with 404 Not Found, indicating the resource couldn’t be located.

10. 500 Internal Server Error 💥

  • Explanation: The server encountered an unexpected condition that prevented it from fulfilling the request. This is often due to server misconfigurations or bugs.

  • Real-Life Example: You place an order at a restaurant 🍽️, but there’s a kitchen mishap (e.g., an oven breakdown), and they can’t prepare your food at the moment.

  • Internet Example: When a website’s server experiences an error (like a bug in the server-side code or database failure) and can’t process the request, the server responds with 500 Internal Server Error, indicating a problem with the server.

11. 502 Bad Gateway ⚠️

  • Explanation: The server, acting as a gateway or proxy, received an invalid response from an upstream server while processing the request.

  • Real-Life Example: You ask a courier service 🚚 to deliver your package, but the courier company gets bad instructions from their distribution center, causing confusion and delay.

  • Internet Example: If a server acts as a proxy and tries to communicate with another server (e.g., a database server) but receives an invalid response, it will return a 502 Bad Gateway status, meaning the upstream server is causing the issue.

I will definitely update this article with more status codes and include tips on how to debug some of the error-related status codes. 🔧👨‍💻

Follow for more such content! 🚀📚

0
Subscribe to my newsletter

Read articles from Shivam Goswami directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Shivam Goswami
Shivam Goswami

🚀 I thrive on diving into the latest technologies, from development to DevOps automation, always eager to code, learn, and share knowledge. Passionate about bringing real-world solutions to technical challenges, I document my journey through my #ErrOnProduction series, where I tackle live issues and share solutions.🐞 While most avoid debugging and error analysis, I enjoy diving into these challenges and uncovering solutions to complex issues. 📈 Transitioning from development to DevOps, I’m chronicling my shift in the #DevToDevops series, exploring DevOps tools and practices. I’m also here to share insights on common tech topics and hands-on projects I’ve worked on. ✍️ Follow along if you enjoy content on DevOps, automation, and coding insights – let’s learn and grow together!