Plugin Support
amoha
(@amoha)
Hi @edviser ,
Thank you for the detailed explanation.
From what you described, the issue is not coming from Media Sweep itself.
The 502 error and the “The response is not a valid JSON response” message indicate that something on your server is blocking or modifying the WordPress REST API response before it reaches the browser.
Since removing one security header fixed the 502 error, it’s very likely that another server-level configuration is still affecting the API response.
Media Sweep relies on the REST API to start a new scan, so if the response is interrupted or altered, WordPress returns “not a valid JSON response”.
Could you please check if the REST API is working on your site by opening this URL in your browser?
https://YOUR-SITE.com/wp-json/
If it doesn’t load correctly or returns an error, then the issue is definitely coming from the server configuration.
Let me know what you find, and I’ll be happy to help you further.
Yes, REST API was disabled by plugins for security and optimization reasons.
Now https://easy-music-learning.ru/wp-json/ loads correctly.
I use 3 plugins for WordPress optimization and security and I did the following:
1. All In One Security (AIOS) – Firewall – WP REST API – Disallow unauthorized REST requests – I turned it off.
2. Clearfy – Code – Clear code – Disable JSON REST API – I turned it off.
3. Admin & Site Enhancement (ASE) – Disable Components – Disable REST API – I turned it off.
But, alas, problem still exists and I can’t scan media files. The same error is shown:
“Failed to start scan: The response is not a valid JSON response”.
And nonetheless I deleted the security header above the error “502 Bad Gateway nginx” still apperas but now not always, but when I log out from admin area or change some settings in WordPress.
By the way, other WordPress websites works on the same web server like the main website and they have the same web server settings. And the plugin works fine there without any errors. So I think the matter is somehow related not to the web-server, but to WordPress and plugins configuration.
P.S.: I think this is the best plugin that exists to clean unused media. I tried many other plugins but none of them can compare with it. As soon as I solve this problem (I hope so) I will definitely write a 5 star review on it.
Finally, the plugin worked and executed the scan! I turned on debug mode in WordPress and error with JSON disappeared but instead of it there was another error “Table mswp_scans cannot be created”.
So I viewed the debug.log and it showed:
[18-Nov-2025 08:34:00 UTC] WordPress database error CREATE command denied to user ‘my username’@’localhost’ for table wp_site_data.wp_mswp_scans for query…
Then I checked the mySQL users rights and detected that creation and altering of mySQL tables were disabled. I enabled them and Media Sweep performed its scan successfully.
So now there aren’t any errors at all!
I analyzed the scan results and noticed that the plugin correctly shows unused images except for those, which are used in galleries, made by Responsive Light-box & Gallery.
Alright then! I’ll test the plugin within 1-2 days and will write a review!
Media Sweep surely must have millions of installations!
Plugin Support
amoha
(@amoha)
Hi @edviser ,
Thank you for the update, and I really appreciate your kind words.
About the images inside Responsive Lightbox & Gallery:
Some gallery plugins store image data in custom tables or custom format, so they’re not detected yet. I’ll explore adding compatibility for it in a future update.
Thanks again for your effort and for considering a 5-star review. it truly helps a lot.
I want to point that enabling Deep scan option in Media scan mode helps to detect images added with Responsive Light-box & Gallery plugin. I didn’t use this option previously, so I slightly misjudged Media Sweep. But with it the plugin processed all media files correctly and marked truly unused media as unused with no mistakes.