The WordPress REST API is an essential feature that allows developers to interact with your WordPress site programmatically. It powers many modern WordPress functionalities, including Gutenberg, third-party integrations, and mobile apps. If you’re encountering a “404” error or other issues when accessing domain.com/wp-json, this guide will help you troubleshoot and fix the problem.
What Causes REST API and WP-JSON Errors?

Several factors can lead to issues with the REST API, including:
- Broken Permalinks
- Faulty Plugins or Themes
- Incorrect .htaccess or Server Configuration
- Security Plugin Restrictions
- PHP Errors or Custom Code
Let’s explore the steps to enable and fix the REST API and wp-json errors.
1. Check and Update Permalinks
The first step is to ensure your permalink settings are correct:
- Go to Dashboard > Settings > Permalinks.
- Click “Save Changes” without altering the current structure.

This action refreshes WordPress’s permalink rules and often resolves 404 errors for REST API endpoints.
2. Verify the .htaccess File
For Apache servers, your .htaccess file must include the correct rewrite rules to enable the REST API. Here is the default .htaccess content:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress- If the
.htaccessfile is missing or doesn’t include these rules, create or update it. - Ensure the file has the correct permissions (typically
644).
3. Test for Plugin Conflicts
Faulty or misconfigured plugins can interfere with the REST API.
- Deactivate all plugins from the Plugins menu.
- Check if
domain.com/wp-jsonworks. - Reactivate plugins one by one, testing the API after each activation to identify the conflicting plugin.
4. Switch to a Default Theme
Sometimes themes contain custom code that disrupts REST API functionality. To test this:
- Switch to a default theme like Twenty Twenty-Three.
- Test the REST API endpoint.
- If it works, investigate your original theme’s
functions.phpfor code disabling the REST API.
5. Review Security Plugin Settings
Security plugins like iThemes Security or Wordfence might block REST API requests. Check their settings and ensure the REST API is enabled.
- Look for options like “Disable REST API” or “Restrict REST API access.”
- Disable such restrictions.
6. Verify Server Configuration
Your server must support WordPress features like pretty permalinks and REST API.
Apache
Ensure mod_rewrite is enabled. Confirm with your hosting provider if unsure.
Nginx
Add the following rule to your Nginx configuration:
location / {
try_files $uri $uri/ /index.php?$args;
}Restart the server after updating the configuration.
7. Enable Debugging
Debugging can help identify underlying issues:
- Open your
wp-config.phpfile. - Add the following lines:
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);- Check the debug log at
/wp-content/debug.logfor REST API-related errors.
8. Reinstall Core Files
If core files are corrupted, reinstall WordPress:
- Go to Dashboard > Updates.
- Click “Reinstall Now.”
This process replaces core files without affecting your content or settings.
9. Check for Custom Code
Review your theme’s or plugin’s functions.php file for custom code that disables the REST API. For example:
add_filter('rest_authentication_errors', function($result) {
if (!empty($result)) {
return $result;
}
return new WP_Error('rest_disabled', 'The REST API is disabled.', array('status' => 403));
});Remove such code to restore REST API functionality.
10. Use the Site Health Tool
WordPress includes a Site Health tool that highlights potential issues:
- Go to Dashboard > Tools > Site Health.
- Look for errors or recommendations related to the REST API.
Follow the provided guidance to resolve issues.
11. Contact Your Hosting Provider
If the issue persists, contact your hosting provider. Ensure the following:
- mod_rewrite is enabled (for Apache).
- Your server meets the minimum requirements for WordPress (PHP 7.4 or higher is recommended).
Conclusion
The WordPress REST API is a powerful tool, and fixing wp-json errors ensures your site functions optimally. By following these steps, you can diagnose and resolve most issues related to the REST API. If you’re still experiencing problems, consider reaching out to WordPress support or your hosting provider for further assistance.
