How to Fix 404 Not Found Error in WordPress
Running a website inevitably comes with fixing bugs and errors every now and again. The 404 Not Found error is one of the most common error messages that will appear on your website, especially as your site’s growing in popularity and page links.
Generally, the 404 error code appears when a website visitor clicks a link to a missing page. But the 404 error can also appear if your site hasn’t been maintained properly for a while, or if the website is under maintenance at the time. This can mean that it’s being updated by you, WordPress, or perhaps one of your themes or plugins.
Luckily, the 404 Not Found error is one of the easiest-to-fix errors you’ll encounter on your WordPress website. We’ll guide you through what the 404 error is exactly, how you can fix it, and give you some extra tips on how to keep your website’s 404 errors user-friendly!
What is the 404 Not Found Error?
In a nutshell, the 404 Not Found error means that the browser couldn’t find the specific URL that it requested. While the client’s browser (it could mean you or a website visitor) successfully connected to the host (which is your site server), the exact slug, for instance, doesn’t exist or couldn’t be found.
Here’s an example:
An example of the 404 Not Found error in Google
In this case, we can see that my browser could successfully access Google’s server, but couldn’t find a page with the particular slug, i.e. givemeanerror in this example. The error code says that “The requested URL /givemeanerror was not found on this server.” So the server is fine, but the page with that slug extension simply can’t be found on this particular server.
When it comes to your WordPress website, it could be the case that a visitor is trying to access a page, that is a URL or a filename, by adding a slug that doesn’t exist. It could be either that the exact URL never existed, or that the requested resources have gone missing. So if your site visitor looked for yourdomain.com/blog-post, but no URL with such a slug (blog-post) exists on your website, they’ll get the 404 Not Found error.
In the case of missing files, let’s say you had a URL leading to a particular image on your website. If you accidentally deleted the image file, or some reconfiguration caused it to disappear, the missing image’s URL will lead the site visitor to the 404 error message, which is a type of an HTTP status code.
The 404 Not Found Error is an HTTP Status Code
On a more technical note, the 404 Not Found error is a HTTP status code. Basically, every time a browser tries to access a URL, it sends a request to the website’s server and receives back the data of that URL alongside a HTTP header. The HTTP header comes with various HTTP status codes, which give information about the status of the request.
When you’re able to access a website without any trouble, you won’t even see the HTTP status code: the fact that everything went fine tells you the status of the request. However, when there’s a problem, and the browser can’t access the URL for some reason, you’ll get a HTTP status code that gives some sort of explanation about what the problem may be.
In addition to 404 Not Found, some additional HTTP error codes are HTTP 405 Not Allowed, HTTP 502 Bad Gateway, and HTTP 503 Service Unavailable. Each of these HTTP error messages indicates a different issue and tries to give you some information on what’s causing it.
In the case of 404 Not Found, the HTTP status code tells us two things:
- The website’s server is up and running.
- The particular URL (post-domain slug) can’t be found on your server.
Variations of the 404 Not Found Error Across Browsers and Sites
Depending on server, browser, and website, you may get the 404 error in a variety of flavors. Essentially, when you see keywords such as 404 or Not Found in an HTTP status code, it’s pretty clear that it’s the same 404 error they’re referring to.
Some variations of the 404 error message include:
- 404 Not Found;
- HTTP Error 404;
- Error 404;
- Page Not Found;
- Not Found;
- We can’t find the page you’re looking for;
- The page cannot be found;
- The requested URL was not found on this server;
- The requested URL /~ was not found on this server. That’s all we know.
Using Custom 404 Error Pages
We saw an example of the 404 error in Google. Here’s another example of the 404 error in the Bing search engine:
In this example, you don’t see the HTTP 404 code, but you do see Page not found which indicates the same problem
Now, as you may have noticed, both Google and Bing have custom 404 error pages. What does that mean? Well, this is what a non-custom 404 error page looks like:
Sample default 404 error page
As you can see, it doesn’t look very user-friendly.
Now, whether you like it or not, 404 error codes are bound to happen. Oftentimes, this won’t even be your fault. Maybe it’s not that you neglected your website and allowed a link to expire, but that a visitor is using a slug that doesn’t exist and never existed in the first place. Even so, you want your visitors to know they’re still on your website, and be able to get redirected to another part of it.
To accomplish this, you’ll need to create a custom 404 error page for your website. Here’s an example of another custom error 404 message on Carwow, a car price comparison site.
The Carwow custom 404 error message
As you can see, it’s very easy for the visitor to get back to another part of the page. This custom 404 error page is quite neat! It keeps with the spirit of the website, and doesn’t frustrate the visitor that the page doesn’t exist.
While this example doesn’t involve the keywords we went over – 404 and not found – it still lets the visitor know that the page they requested isn’t around.
After showing you how to fix the 404 error on your WordPress website, we’ll also go over how you can create a custom 404 page, to keep your visitors happy and entertained. Keep in mind that some WordPress themes come with a custom 404 page by default.
Why You Should Fix the 404 Error on Your WordPress Website
The last stop we want to make before getting to the fixing of the issue is to go over why it’s so important that you fix the 404 error as soon as possible.
If the 404 Not Found error comes from a mistyped URL on the part of your site visitor, you’ve got nothing really to worry about.
Error 404 Can Affect Your SEO Rankings
However, if you have broken URLs on your website which are causing this issue, then Google crawlers won’t be able to inspect your website, which will mess with your SEO rankings. Neglected permalink issues, which can cause 404 errors throughout your website, can result in the same negative impact on SEO.
Error 404 Can Affect Your Website’s Performance
Additionally, if your website generates multiple 404 errors on individual pages, you can end up with various performance issues on your hands. This is because 404 error codes aren’t cached, and will demand that browsers re-access the content each time the 404 error pages are loaded.
So, to prevent these sorts of drawbacks, make sure to fix the 404 error as soon as possible! Don’t worry though, doing this is easy. Which finally brings us to how you can do it.
How do I fix Error 404 Not Found in WordPress?
There are two main ways to fix the 404 error on your WordPress website:
- Updating permalinks;
- Setting up redirects for content that was renamed or moved elsewhere.
Both solutions are quite easy, so let’s dive in.
There are two ways to update your site’s permalinks. The first one is through the WordPress dashboard, and the second one is through your .htaccess file. Try the former way first as it’s easier, and if that step doesn’t work, move on to the latter. Also keep in mind that the .htaccess way works only if your host uses Apache rather than Nginx.
Updating Your Permalinks from the WordPress Dashboard
A simple permalink update can resolve the 404 error.
Doing this is simple:
- Go to your WordPress admin dashboard > Settings > Permalinks.
- Click on Save Changes. If you’re using a Custom Structure, make sure the field is filled.
Update your permalinks from the WordPress admin dashboard
That’s it! Now, try loading the page that was showing the 404 error code when it shouldn’t have. Hopefully, the page now loads properly. If not, let’s try doing this by updating your .htaccess file. The issue may be caused by misconfigurations or missing file permissions in this file.
Updating Your Permalinks from the .htaccess File
To do this:
- Log in to your host’s server via an FTP client.
(If you haven’t done this before: type in ftp://[FTP-server-IP-or-domain-name] into the search bar of your browser or file explorer, filling in your own server IP or domain name. Use the username and password supplied by your web host provider when you first signed on with them to log in. Contact your host if you can’t find this information.)
- Find the .htaccess file. This is a hidden file format, so if you can’t see it, simply set all files to visible.
- Download the .htaccess file. You can find it in the same folder as /wp-content/ and /wp-admin/.
- Open the .htaccess file in any code or text editor, like Notepad.
- Copy and paste a new code into the .htaccess file, save it, and re-upload it to the server.
Depending on which version of WordPress you’re using, you can find the appropriate code in the WordPress .htaccess database.
There are different codes that you should use depending on whether you’re using WordPress Basic or Multisite, and also depending on which version of WordPress you’re running your site on.
Here’s an example of what the code looks like for WP Basic:
The code you need to paste into your .htaccess file if you’re using Basic WP
Hopefully, this has resolved the 404 error on your WordPress website.
If not, the issue may be due to content that has been renamed or moved, and you forgot to update the URL slugs appropriately. Our next step covers how to do just that.
2. Creating 301 Redirects for Content that Was Renamed or Moved
Let’s say you updated the permalinks, but the 404 error persists on a particular page or file direction URL. These are the two most likely scenarios causing this issue:
- You changed the slug in that page’s URL. Let’s assume that you have a certain piece of content, like a blog post. You may have bulk-changed the post slugs (from, say, sample.com/blog-post-1 to sample.com/post-1), and failed to redirect the old URL to the new one.
- Moved the content elsewhere on your website. For instance, this may happen if you deleted an existing image with a certain URL address from one page, and moved it to another.
In both cases, the original URL will no longer be backing the same content, so instead, visitors will encounter the 404 error. To easiest way to remedy this is by creating 301 redirects from the old URL address of the content to the new. When visitors try to visit the outdated links to that piece of content, they’ll be redirected to the updated URL without ever coming across the 404 error.
For future reference, make sure to add a redirect as soon as you rename or move a piece of content.
Sometimes, WordPress automatically sets up redirects to such content. However, this isn’t a very reliable method. The best way to set up 301 redirects for your website is by using a redirect plugin, such as the free Redirection plugin by John Godley.
The Redirection plugin can help you manage redirects from old URLs and keep track of 404 errors
This plugin allows you to manage 301 redirections from old to new URLs and keep a log of all redirects on your website, including the 404 error message. In a nutshell, it will help you reduce the number of 404 errors, which can overall help you maintain and boost your SEO rankings.
To use the Redirection plug, first install it through your WordPress admin dashboard. Once you’ve done that:
- Go to Tools > Redirection.
- Enter the URL of the page that’s showing the 404 error in the box titled Source URL and then the URL of the page you want it to be redirected to in the box titled Target URL.
How to use Redirections to fix the 404 error
- Lastly, just click on Add Redirect. That’s it! Having this plugin in your arsenal will always help you stay on top of 404 errors, and overall any redirects occurring on your website.
Even though you now know how to fix the 404 Not Found error in WordPress, it doesn’t mean that this error won’t appear on your website. Even if you keep everything on your end neat and tidy, visitors may still enter the wrong slug and end up seeing the 404 error page.
So, to keep the 404 error in tune with your website, and to prevent visitors from leaving, let’s look at how you can create a custom 404 error page on WordPress.
How To Create a Custom Error 404 Page on WordPress
As we mentioned earlier, having a custom 404 error page is always a good idea. Fun and creative 404 error pages are much more likely to keep visitors on your website and redirect them to other content than the default, blank, cold-looking 404 page. In a nutshell, a custom 404 error page can help with SEO rankings as well as branding.
The easiest way to create a custom 404 error page is to use a WordPress plugin. There are tons of free and premium plugins you can choose from.
You can start off with the free 404page plugin.
Using the 404page plugin is super easy – you can access it from the WordPress Page Editor > Appearance > 404 Error Page. From here, you’ll be able to create a custom 404 error page.
The purpose of a custom error 404 page is to take your visitor from a dead end and lead them back to viable content on your site. That’s why the 404page plugin allows you to add a search box, contact info, and links on your custom 404 page. All of these features are meant to bring the visitor to existing content within your website.
Overall, though, try to keep your 404 error page light on data such as images, so it doesn’t unnecessarily overwhelm your limited WordPress storage.
A Few Final Words…
We went over a lot of stuff here, so let’s make a quick review on how to handle 404 Not Found errors on your website.
First, as we said – the 404 error is inevitable. The 404 error can be caused by something on your end, like outdated permalinks or moved/renamed content. There are easy solutions if this is the case, and they are:
- Updating your permalinks through WordPress or your .htaccess file.
- Setting up 301 redirects for moved or renamed pieces of content within your website. This way site visitors will be redirected to existing content without ever facing the 404 Not Found error.
Handling 404 errors as soon as they occur improves SEO rankings and website performance. If you leave dead links unattended for too long, Google won’t be able to crawl your web pages and retrieve information about your website.
Even if the error is not caused by some misconfiguration on your end, a faulty slug written next to the domain by a site visitor will lead them to a 404 error page. This is where the importance of custom 404 pages enters the picture.
Creating a custom 404 page for your website will also help you improve SEO rankings. Additionally, it adds to your site’s branding and keeps your visitors more likely to extend their experience on your website. The easiest way to create a custom 404 page is by using a WordPress plugin.
When a visitor sees a custom 404 page that maintains your site’s theme and, perhaps, edginess, they’re much more likely to stick around, search for a particular piece of content via the 404 page, follow a link to another part of your website, contact you, and so on. This turns customers to potential leads and brings you potential sales, and this is the ultimate goal!
View Related Articles
But what are redirects, and why are they important? What are the different types of redirects? We’ll fill you in on everything you need to know about redirects, and most importantly – how to do them on your WordPress site.
What are the benefits of opting for a dedicated IP? And perhaps most important of all – do you really need one? Let’s take a closer look at all the questions surrounding dedicated IPs so that you can better understand who needs a dedicated IP and when.
Creating a website and publishing it online may sound intimidating. Beginners often worry that they need a lot of technical know-how and a decent level of programming skills to get a website up and running. However, this hasn’t been true for a long, long time.