Fix WordPress REST API Errors That Block Loading, Editing, or Saving
Many WordPress plugin dashboards, theme options, and block editor screens rely on the REST API to load data and save changes. This guide helps you diagnose and fix requests that return 404 errors, redirects, 403 access-denied responses, or non-JSON pages such as security challenges, preventing a screen from loading, editing content, or saving changes.
In this article
Identify a REST API Failure
The WordPress REST API is the channel that plugin dashboards, the block editor, and some theme screens use to load data and save changes in the background, without reloading the page. When a request returns a 404 "not found" response, a 403 "forbidden" response, a redirect to your homepage, or a security challenge instead of the expected JSON data, the screen cannot complete its action. JSON is the structured text data WordPress screens expect; an HTML error page or human-verification challenge is not a usable replacement. This can show up as:
- A plugin dashboard or settings screen that freezes or never finishes loading.
- An editor that cannot load or let you edit posts or pages.
- An editing or saving failure limited to one browser, such as Safari.
- Buttons or controls that stay disabled after an action is started.
- A save action that fails, sometimes with an "invalid JSON response" or similar error.
- A background status check (for example, tracking the progress of a long-running task) that never completes.
Security filters can treat requests differently based on browser or request characteristics, so one browser may work while another is blocked. A browser-specific failure alone does not prove that Cloudflare or your active theme is responsible: inspect the failed request and matching security logs before changing either.
One example of this pattern is the Optimole error "An unexpected error occured while pulling the offloaded back to your site", which can appear during an image rollback. If you're troubleshooting Optimole's Image Storage rollback and see this message, or your rollback screen is frozen with controls disabled, this is one possible cause worth ruling out — but the message on its own doesn't confirm it. The same routing failure can also block a plugin from connecting to its remote service at all, or prevent a save action in an unrelated part of WordPress, such as saving a widget. Testing the REST API directly, as described below, is how you confirm whether this is the cause.
📝 Note: If your styling looks broken or a widget save fails specifically after an HTTP/HTTPS URL mismatch, see Styling Breaks, Invalid JSON Errors, or Failed Widget Saves (HTTP/HTTPS Mismatch) instead — that's a separate, more specific cause with its own fix.
Test the WordPress REST API
Before changing any settings, confirm whether the REST API is actually reachable on your site.
- Open a new browser tab and visit your site's REST API base endpoint:
https://yoursite.com/wp-json/(replaceyoursite.comwith your own domain). - Check what you get back:
- If the page displays a block of JSON text (data inside curly braces
{ }), the REST API base endpoint is reachable. This does not prove every REST route works: a route (the specific API address an action uses) can still return403while/wp-json/returns JSON. - If the page shows a 404 "not found" error, or redirects you to your homepage, the REST API is not being routed correctly.
- If it shows
403, an HTML error page, or a security challenge, check security and hosting restrictions below.
- If the page displays a block of JSON text (data inside curly braces
- If
/wp-json/failed, test the alternate route:https://yoursite.com/?rest_route=/.- If this version returns JSON while
/wp-json/returns404or redirects to your homepage, the REST API itself is working, but the "pretty" URL rewrite path that turns/wp-json/into a readable link may be broken. This points you toward a permalink or web server rewrite problem rather than the REST API being completely disabled. If/wp-json/returns403or a challenge instead, check security restrictions rather than assuming a rewrite problem. - If both versions fail, check security and hosting restrictions below; these tests alone do not establish whether all REST routes are blocked.
- If this version returns JSON while
Next, inspect the request used by the action that fails, even if the base endpoint returns JSON:
- In the originally affected browser, open the editor or plugin screen where the problem occurs.
- Open the browser's developer tools from its menu and select the Network panel. This panel lists requests sent by the browser and the responses received. If developer tools are hidden, enable them using your browser's help instructions.
- With the panel open, repeat the failed action: reload the editor if it cannot load, or try editing or saving again.
- In the request list, filter or search for
wp-jsonand select the failed request. If your site uses the alternate REST URL, also look forrest_route. - In the selected request's details, record the full request path, request method (such as
GETfor loading data orPOSTfor sending changes), response status (such as403), and the time of the attempt, including your time zone. Inspect the response content too: note whether it contains JSON, an error page, a redirect, or a security challenge.
A 403 means access was denied, but does not by itself identify the firewall or rule responsible. Use these details to match the request to a security event rather than assuming every 403 comes from Cloudflare.
If the failed request is specifically /wp-json/batch/v1 with status 403 while saving widgets, follow Fix “Not a Valid JSON Response” When Saving WordPress Widgets (403) for the widget-specific guidance and temporary alternatives.
Refresh WordPress Rewrite Rules
If /?rest_route=/ returned JSON but /wp-json/ returned 404 or redirected to your homepage, refresh WordPress's rewrite rules (the internal map that turns readable URLs into the requests your server understands). A 403 or security challenge instead calls for the security checks below.
- From your WordPress dashboard, go to Settings > Permalinks.
- Without changing any options, click Save Changes. This rebuilds your site's rewrite rules.
- Test
https://yoursite.com/wp-json/again in your browser. It should now return JSON. - Go back to the screen or action that was failing and try it again.
Check Security and Hosting Restrictions
If refreshing permalinks didn't fix it, both base-endpoint tests failed, or the action's specific request returns 403 or a security challenge, check for restrictions between the browser and WordPress. These can include:
- A security plugin on your site that blocks or restricts REST API access as part of its firewall or hardening features.
- A redirect rule added by your theme, another plugin, or your
.htaccessfile (on Apache) or server configuration (on Nginx). - A hosting-level firewall or web application firewall (WAF), a security filter that reviews requests before they reach WordPress.
- Cloudflare WAF rules or bot-protection controls that block or challenge legitimate WordPress requests.
To narrow this down:
- Repeat the failure in the affected browser and note the exact route, method, response status, and timestamp, including your time zone, from the Network panel.
- If you manage a security plugin or hosting firewall, review its security logs for that request and time. Check which rule and action caused the block rather than allowing REST API traffic generally.
- If your site uses Cloudflare, select your site in the Cloudflare dashboard and open Security > Events. Find the event matching the request path, method, and time you recorded. Open it and inspect the action (such as block or challenge), responsible rule or bot-protection control, and browser/request identity details shown. Compare these with the browser's response status. A matching blocked or challenged event confirms Cloudflare intercepted that request; a failure in Safari alone does not.
- Adjust only the rule confirmed to cause the failure, or use the narrowest supported exception for the affected request, including its exact route and method and authenticated context where supported. Do not allow all
/wp-json/traffic or assume a particular bot-protection setting caused the problem. If the control does not support a narrow exception, ask your provider which targeted protection is appropriate. - If you cannot find or manage the responsible rule, contact your hosting provider or the person who manages Cloudflare. Include the exact route, method, status, timestamp with time zone, and any matching event's action and rule details. Ask them to:
- Confirm that your site's permalink and rewrite rules are configured correctly at the server level (Apache
.htaccessor Nginx configuration). - Check for any redirect rule that specifically affects
wp-jsonrequests. - Review their WAF, firewall, or bot-protection logs for the matching request and allow only the confirmed legitimate request or adjust the responsible rule.
- Confirm that your site's permalink and rewrite rules are configured correctly at the server level (Apache
⚠️ Warning: Only adjust security settings temporarily to test the fix. Don't leave firewall or security protection permanently disabled — re-enable it once you've confirmed which specific rule was causing the block, and keep only the adjustment needed to allow the REST API request in question.
Verify the Fix
Once you've made a change, confirm it worked before considering the issue resolved:
- Visit
https://yoursite.com/wp-json/again and confirm it returns JSON. - In the originally affected browser, return to the plugin screen or editor and repeat the same loading, editing, or saving action with the Network panel open.
- Confirm you can edit or save successfully, without freezing, disabled controls, or an error message.
- Select the previously failing REST request and confirm it no longer returns the blocking
403, redirect, error page, or security challenge, and returns the response the action expects. - Restore any protection temporarily disabled for testing, leaving only the narrow adjustment for the confirmed request, then repeat the action to confirm it still works with protection enabled.
If /wp-json/ now returns JSON but the original action still fails, the specific route may still be blocked. Return to your host, security plugin, or Cloudflare administrator with the retried request's route, method, status, and timestamp, and ask them to check the matching logs rather than the REST API generally.
