WordPress wp-admin/async-upload.php 403 Forbidden

I was trying to upload image from WordPess media and was getting 403 message. I searched and tried every method. Some of them include:

  • disabled modsecurity
  • created alternate uploads folder
  • given 777 permission to uploads folder

At last I turned on WP_DEBUG log and got following error:

WordPress database error: [Duplicate entry '794356' for key 'PRIMARY']
 INSERT INTO `wp_posts` (`post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_content_filtered`, `post_title`, `post_excerpt`, `post_status`, `post_type`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_parent`, `menu_order`, `post_mime_type`, `guid`) VALUES (1, '2017-08-20 11:51:09', '2017-08-20 15:51:09', '', '', 'test', '', 'inherit', 'attachment', 'open', 'closed', '', 'test-3', '', '', '2017-08-20 11:51:09', '2017-08-20 15:51:09', 0, 0, 'image/jpeg', 'https://mysite.com/wp-content/uploads/2017/08/test-32.jpeg')

This means something is wrong with my database. From above error I tried to fix wp-posts table

from ssh run following commands:

# mysql
 mysql> use database_name;
 mysql> REPAIR TABLE wp_posts;
 mysql> exit

There may be various other reasons. You can Google it. For reference go to this website.

Leave a Reply

Your email address will not be published. Required fields are marked *