New tool

Check your website for php2shell exposure. Get a free, quick security check for your PHP website.

Try the php2shell Checker

Understanding Common HTTP Status Codes and How to Resolve Them

Learn about common HTTP status codes like 403, 404, 502, 503, and 401. Understand their causes and solutions with practical examples and code.

Understanding Common HTTP Status Codes and How to Resolve Them


HTTP status codes indicate the result of a client’s request to a server. While some are informational, others signify errors that need attention. In this guide, we cover common HTTP status codes, their meanings, and practical solutions to resolve them.

1. HTTP 403 Forbidden

The 403 error occurs when the server denies access to the requested resource.

  • Reason: Missing or incorrect permissions for the requested file or directory.
  • Solution:
    1. Check file and directory permissions. Ensure they’re set correctly (e.g., chmod 644 filename for files and chmod 755 directoryname for directories).
    2. Verify the .htaccess file does not restrict access unnecessarily.
    3. Ensure the server’s IP whitelist includes your client’s IP address if applicable.

2. HTTP 404 Not Found

The 404 error indicates the server couldn’t find the requested resource.

  • Reason: The URL is incorrect or the resource has been moved or deleted.
  • Solution:
    1. Check for typos in the URL.
    2. Update broken internal links using tools like Dead Link Checker.
    3. Restore the missing resource if it was deleted accidentally.

3. HTTP 502 Bad Gateway

The 502 error occurs when the server acting as a gateway or proxy receives an invalid response from an upstream server.

  • Reason: Temporary server overload or communication issues between servers.
  • Solution:
    1. Restart the web server. For example, use sudo service nginx restart or sudo systemctl restart apache2.
    2. Verify server-to-server communication by checking error logs (e.g., /var/log/nginx/error.log).
    3. Ensure the upstream server is operational.

4. HTTP 503 Service Unavailable

The 503 error indicates the server is temporarily unavailable to handle requests.

  • Reason: Server overload, maintenance, or a misconfigured load balancer.
  • Solution:
    1. Check server load and optimize resource usage using commands like top or htop.
    2. Update maintenance configurations to return an appropriate response.
    3. Restart services if necessary: sudo systemctl restart nginx or apache2.

5. HTTP 401 Unauthorized

The 401 error occurs when authentication credentials are missing or incorrect.

  • Reason: Invalid credentials or expired tokens.
  • Solution:
    1. Verify login credentials and ensure they are entered correctly.
    2. Check and update API keys or tokens if accessing APIs.
    3. If using Basic Authentication, verify the .htpasswd file contains the correct credentials.

Conclusion

Understanding and resolving HTTP status codes is essential for maintaining a healthy website. Regularly monitor logs and use analytics tools to identify and fix errors promptly. For expert assistance, contact WebCareSG. We provide comprehensive support to ensure your website remains functional and user-friendly.


Related WebCare Solutions

How to Fix Confusing Website Navigation: A Step-by-Step Guide for Singapore Business Owners

Confusing website menus drive visitors away. Learn how to audit, restructure, and improve your website navigation to keep visitors engaged and boost conversions.

What Is a Page Builder and Should You Use One? (Elementor, WPBakery, etc.)

Page builders like Elementor and WPBakery let Singapore business owners edit their own websites without code. This guide explains what they are, the best options available, and how to decide if one is right for you.

Why is My Contact Form Not Working? Troubleshooting Guide

Discover common reasons why your website contact form might not be working and learn how to troubleshoot email settings, plugin configurations, and server issues.

Ready to get started?

Focus on your business while we fix your website. Contact WebCareSG today for fast, reliable solutions!

Whatsapp us on

+65 9070 0715