What Is a 404 Status Code?
The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
A 404 status code does not indicate whether this lack of representation is temporary or permanent; the 410 Gone status code is preferred over 404 if the origin server knows, presumably through some configurable means, that the condition is likely to be permanent.
A 404 response is cacheable by default; i.e., unless otherwise indicated by the method definition or explicit cache controls1.
404 CODE REFERENCES
Rails HTTP Status Symbol
Go HTTP Status Constant
Symfony HTTP Status Constant
Python2 HTTP Status Constant
Python3+ HTTP Status Constant
Python3.5+ HTTP Status Constant
Apache HttpComponents Core
404 status code example
Here is an example of a request and response that could result in a 404 status code:
GET https://example.com/non-existent-resource HTTP/1.1
HTTP/1.1 404 Not Found
Date: Wed, 16 Mar 2023 12:00:00 GMT
The resource was not found
In this example, the client is sending a GET request to access a resource at
https://example.com/non-existent-resource. However, this resource does not exist on the server.
The server responds with a 404 Not Found status code, which indicates that the requested resource could not be found. The response also includes a message body with a plain text message that provides additional information about the error.
The server also includes several headers in the response, such as
Content-Length, which provide additional information about the response.
The 404 status code is a common HTTP status code that indicates that the requested resource was not found on the server. This could occur if the resource has been deleted, moved, or renamed, or if the client has entered an incorrect URL.
How to fix a 404 status code
Here are some ways to fix a 404 status code:
- Check the URL: The first step in fixing a 404 error is to check the URL that was entered by the client. Make sure that the URL is correct and matches the resource that the client is looking for. If the URL is incorrect, update it to the correct one.
- Check the server logs: Check the server logs to see if there are any errors or issues that could be causing the 404 error. Look for any errors related to the resource that the client is trying to access.
- Check the server configuration: Check the server configuration to ensure that the resource is configured correctly. Make sure that the resource exists and is mapped to the correct location on the server.
- Check the permissions: Check the permissions for the resource to ensure that the client has permission to access it. If the permissions are incorrect, update them to allow access to the resource.
- Implement a redirect: If the requested resource has been moved or renamed, you can implement a redirect to the new location. This will allow the client to access the resource using the new URL.
- Implement a custom 404 page: If the requested resource cannot be found, you can implement a custom 404 page to provide the client with helpful information about what went wrong and how to proceed.
- Update links: If the resource has been moved or renamed, update any links that point to the old location to point to the new location. This will help prevent future 404 errors for other clients who may be accessing the same resource.
FAQs about 404 status codes
Learn more about 404 not found errors in our FAQ:
What is a 404 page?
A 404 page is a web page that is displayed to a user when they try to access a resource that cannot be found on a server. This can occur if the URL that the user entered is incorrect or if the resource has been moved, deleted, or renamed.
A 404 page is typically designed to provide helpful information to the user and guide them towards finding the resource they are looking for. The page may include a message explaining that the resource could not be found, suggestions for what the user can do next, links to other pages on the website, or a search box that the user can use to find the desired content.
Should you create a custom 404 page?
Customizing the 404 page on a website is a good practice, as it can help improve the user experience and prevent users from leaving the site in frustration. A well-designed 404 page can also help maintain the credibility and professionalism of a website.
In some cases, a 404 page may also include a link to report the issue to the website’s administrator or support team. This can help the website owner identify and fix any issues that may be causing the 404 error, and ensure that users are able to access the content they are looking for.
Do 404 status codes affect search engine optimization (SEO)?
Yes, 404 errors can affect SEO, as they can result in a negative user experience and impact the website’s search engine rankings. Here’s how:
- Loss of traffic: If a user encounters a 404 error when trying to access a page on a website, they may leave the site and search for the content elsewhere. This can result in a loss of traffic and potential customers for the website.
- Broken links: If a website has a lot of 404 errors, it can signal to search engines that the site is not well-maintained and has a lot of broken links. This can negatively impact the site’s search engine rankings.
- Decreased crawl efficiency: Search engine crawlers will continue to crawl a site even if they encounter 404 errors. This can decrease the crawl efficiency and result in a slower crawl rate for the site.
- Negative impact on user experience: A website with a lot of 404 errors can negatively impact the user experience, as it can be frustrating for users who are trying to access content on the site. This can result in a higher bounce rate and lower engagement metrics, which can in turn negatively impact the site’s search engine rankings.
To mitigate the impact of 404 errors on SEO, it’s important to ensure that any broken links are fixed as soon as possible, and that users are redirected to relevant content if a page is no longer available. Additionally, implementing a custom 404 page can help guide users to other relevant content on the site and improve the overall user experience.
- Learn about web development
- Learn about SEO
- Web development services from WebFX
- SEO services from WebFX
- MDN Web Docs