Fix & troubleshoot

WordPress REST API returns 404 (/wp-json/ not found)

/wp-json/ returns 404 Not Found? Test ?rest_route=/, re-save permalinks, fix .htaccess or the Nginx rule, and clear the cache. Step by step.

Rather not do this yourself?Book a free setup call and we will connect your site to Claude or ChatGPT with you, live. Pick a time →

Why it happens

/wp-json/ is not a real folder on your server. It is a pretty URL that WordPress answers through the same rewrite rules as your permalinks. When those rules are missing or broken, the web server looks for a real wp-json folder, finds nothing and returns 404. The usual reasons are an .htaccess file that was lost or not copied during a migration, an Nginx config without the WordPress try_files line, Plain permalinks, or a cache or CDN still serving an old 404. The REST API itself is usually fine, and the fallback address ?rest_route=/ proves it in a few seconds. The same fault is behind the block editor error "Updating failed. The response is not a valid JSON response."

The fix

Step by step

Work through these in order. Most people are done by step two.

1

Test the fallback address

Open https://yoursite.com/?rest_route=/ in your browser. If you see a page of JSON, the REST API works and only the pretty /wp-json/ address is broken, which is a rewrite problem: carry on with the next steps. If the fallback also fails or shows an error, a plugin is restricting the REST API instead; see our page on the REST API being blocked by a security plugin.

2

Re-save your permalinks

Go to Settings, Permalinks and click Save Changes without changing anything. WordPress rebuilds its rewrite rules and, on Apache, rewrites .htaccess if it can. This alone fixes most cases, especially right after a migration.

3

Move off Plain permalinks

If Settings, Permalinks is set to Plain, pretty addresses such as /wp-json/ do not exist on your site. Choose Post name (or any option other than Plain) and save. Check a couple of old links afterwards; WordPress redirects most of them.

4

Apache: check the .htaccess file

In your WordPress folder, open .htaccess. It should contain the standard block that starts with # BEGIN WordPress and ends with # END WordPress, including the line RewriteRule . /index.php [L]. If the file is missing, empty or not writable, create it with that block or make it writable and re-save permalinks. The server also needs mod_rewrite and AllowOverride All, which your host can confirm.

5

Nginx: add the WordPress try_files rule

Nginx ignores .htaccess. In the server block for your site, the location / section needs try_files $uri $uri/ /index.php?$args; so that unknown addresses, /wp-json/ included, are passed to WordPress. Reload Nginx after the change, or ask your host to add it.

6

WordPress in a subfolder? Use the full address

If WordPress lives in a subfolder such as /blog/, the REST API is at https://yoursite.com/blog/wp-json/. Use the same address, with the subfolder, when you connect the site.

7

Clear every cache

Caching plugins, server caches and CDNs such as Cloudflare can keep serving a 404 after you fixed it. Purge them all, then test /wp-json/ again in a private window.

8

Reconnect the site

When https://yoursite.com/wp-json/ shows JSON, reconnect the site in your connector. If you now get 401 or 403 instead of 404, the address works and the remaining problem is the login; see our 401 and 403 fix.

Still stuck?

If ?rest_route=/ works but /wp-json/ still returns 404 after re-saving permalinks and clearing caches, the server is not passing requests to WordPress. Send your host this exact sentence: "/wp-json/ returns 404 but ?rest_route=/ works; please check the rewrite rules (mod_rewrite and AllowOverride on Apache, or try_files on Nginx)". If both addresses fail, message us with your site address and we will look at it with you.

FAQ

Related questions

01Why did /wp-json/ break after I moved my site?

.htaccess starts with a dot, so many copy tools and hosts skip it as a hidden file. Without it, Apache has no rewrite rules. Re-saving permalinks in the new site usually recreates it.

02Is this the cause of "Updating failed. The response is not a valid JSON response"?

Very often, yes. The block editor saves through the REST API. When /wp-json/ returns a 404 page instead of JSON, the editor shows that message. Fixing the 404 fixes the editor too.

03Can I just use ?rest_route=/ permanently?

WordPress supports it, but many apps and connectors expect /wp-json/. Fixing the rewrite rules is quicker than finding a workaround for every tool.

04My posts load fine, so why would rewrites be broken?

Some caches serve pages without asking WordPress, and some setups have a rule that sends only certain paths to WordPress. If posts work but /wp-json/ does not, look for a cache or a server rule that treats /wp-json/ differently, or a plugin hiding it.

05Does a security plugin cause 404 instead of 401?

Some hardening plugins answer with 404 on purpose to hide the API. If ?rest_route=/ also fails, check the REST API option in your security or hardening plugin.

Your AI is ready to work.

Connect WPTaskify and turn conversations into real actions.

Start Free