Fixing WordPress 502 errors caused by incorrect WP-Optimise plugin permissions
Published on 31st August 2025 Estimated Reading Time: 1 minuteWhen I started getting a 502 status error on saving a WordPress post, it naturally was concerning, even if I found that the post was saved in the background. Inspection of the Nginx error log was in order, given that an invalid response was triggering the Bad Gateway message. That revealed that the WP-Optimise plugin was triggering the error when trying to access a location on the server. The cause was having incorrect permissions, which was sorted by something like the following:
chown -R www-data:www-data /var/www/html/wp-content/uploads/wpo
chmod -R 755 /var/www/html/wp-content/uploads/wpo
If it were to happen to you, the location may be different, as mine is for me. What you see above is the default. The chown
command is assigning www-data
as the owner and group for the specified location, with the -R switch triggering recursion for this action. After that, the chmod
command is assigning full permissions for the owner, as well as read and execute for everyone else. All of this is to enable WP-Optimise to update its logs, the failure of which was causing the 502 messages in the first place.
Please be aware that comment moderation is enabled and may delay the appearance of your contribution.