WordPress does some weird things, like when you try to publish a post, and it returns a 404, not found page. This is of course, unexpected behavior.
In this case, you click to publish the post, and while it loads to the 404 error, you will see in your browser address area, or where the URL of the page is, that it says /wp-admin/post.php. When you publish a post, it will reload the page and give you a confirmation that the post has been published.
There can be a variety of things that make the WordPress post return a 404 error, so you will have to troubleshoot it out to pinpoint what is causing the issue. I’ve put together a list of steps to try.
How to Fix WordPress Posts Returning a 404 Error
1 Deactivate plugins, and then re-activate them one by one.
As you reactivate each plugin, try to publish the post and see if it will publish without returning a 404 error.
2 Set the theme to a default theme, like Twenty Sixteen.
This will eliminate the possibility that the theme may be part of the problem. Like the plugin check, try publishing the post. If it still sends you to a 404 page, then it’s not a problem with the theme.
3 Uploaded a fresh installation of WordPress.
I’ve read in a few places that people say you should check to see if the post.php file actually exists. Instead of doing this, I just give fresh WordPress files. You can either re-install from your WordPress Updates area (Under Dashboard > Updates) in your WordPress admin, or manually upload the files via FTP or SFTP.
This eliminates checking, and makes sure you have fresh WordPress files. Please note that if you do manually replace your files, to not upload the wp-content folder in the WordPress downloadable zip file.
4 Check your .htaccess file to make sure it is correct.
The code that WordPress inserts into your .htaccess file, if you are using /%postname%/ for your permalink structure should look like:
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
5 Repair and optimize database tables.
You can do this using phpmyadmin, or if you don’t like to mess with it, you can using WP-Optimize.
6 Resave permalinks.
Try resetting your permalinks. You can try setting it to another choice, but you shouldn’t have to. Simply making sure that the correct permalink structure is selected, and then clicking on the Save Changes button should do it.
7 Talk to your web host to check to see if they need to whitelist a mod_security rule.
If none of these work, talk to your web host. They can check to see if your mod_security rules have been altered, and whitelist it.
Hopefully, these steps will help you troubleshoot the issue you’re having when you publish a post and it returns a 404 error.
What worked for you?
stefan says
Hey, thanks for this! I had no idea how to solve my 404 error!
Amar kumar says
Hey Nile,
WordPress is a powerful CMS. Sometimes a slight tweak can make our website inaccessible. Finding a solution for any WordPress problem is extremely easy.Usually in this scenario a user can access their WordPress admin area, their blog’s main page, but when accessing a single posts they get a 404 Not found error.
This usually happens if your .htaccess file got deleted or something went wrong with the rewrite rules.WordPress is a content management system that processes its own internal rewrite array as a part of its permalinks feature. Thanks for sharing much interesting thought with us, it is really sound very beneficial for every blogger to learn this factors to get success over this issue.
With best wishes,
Amar kumar
Nile Flores says
Hi Amar!
This is not always the htaccess. That is why I’ve listed all 7 steps. In the past 13 years I’ve been using WordPress, 6/10 times, the solution was needing to get whitelisting with a mod security.
Dumaji says
I was having issue with the .htaccess file. Your post saved my lot of productive time. I was going to hire a wordpress developer because of this issue.
Your article saved my few dollars. Thanks for nice explanation which worked for me like butter.
Alok Sahu says
Hello Nile Flores!
Great post! my website have many 404 error after reading your post I can fix my 404 error
Thanks for posting
Anastasia says
Am not sure if these steps will help solve the problem for me. The last time it happened on my WordPress it was a web host that fixed it. Now I guess I can give it a practical trial by myself whenever the error pops up again. Am glad I stumbled on this article. Thanks for sharing.
Nile Flores says
Anastasia – that’s why #7 was mentioned, as it can boil down to a hosting issue.
Gagan Chauhan says
Finally, a great post that explains it all! Glad to have found your post, Nile! I was facing this error on several pages. Thanks for sharing!
Munna Hossain says
Informative post. It is really an irritating problem that is post returning 404 error. Finally, I have got an excellent article. I hope it will be helpful for me. Thanks for sharing.
Shiv Saroya says
Hi,
i am a blogger and very familiar in WordPress, every blogger facing 404 error issue. there are many reason of 404 error. finally your post is a good solution for fixing 404 error. thanks for post a great post.
Snigdha Saha says
Hi Nile,
I am new to wordpress and my blog also new. Thanks god I don’t face this kind of 404 error problem. But I would like to thank you for sharing this informative post, I learn new things and I am sure it will help me later. Thank you again 🙂
Ashik Ahmed says
I think WP-Optimize is best plugin for this problem, i use it most of the time and its works. Thanks for your share.
Faura says
Very good information especially for me, a new comer on wordpress. Thanks!
Saud Razzak says
Very informative and useful article for WordPress beginners!.