How to fix WordPress 404 Error on saving a new post or updating a post?

I was working on a blog post and had written a part of it and saved it. After some days, I visited the post again to complete it but it would not save, clicking on “Save Draft” button displayed a 404 not found page.

I tried to edit the post with same new content multiple times but same 404 error. Then, since I already had some post content saved, I tried to save it again with no update; it worked. So, I started updating the post content in steps, it was working and content was saving.