If you're encountering a 404 Not Found error try these steps:
β
β
1. Verify Permalinks Are Set Correctly
WooCommerce API requires pretty permalinks to be enabled.
Navigate to WordPress Admin Panel > Settings > Permalinks.
Ensure the permalink structure is not set to Plain (e.g.,
/?p=123
).Select any other structure, such as Post name, and click Save Changes.
2. Check if the REST API is Enabled
Go to WooCommerce > Settings > Advanced > REST API.
Ensure that the REST API is enabled and there are no restrictions.
3. Confirm the API Endpoint URL
The default API URL format for WooCommerce is:
https://yourstore.com/wp-json/wc/v2/
Replace
yourstore.com
with the actual domain of the WooCommerce store.Test the base URL (
/wp-json/
) in your browser to ensure it works. If this returns a 404, the REST API might not be accessible.
4. Verify Server Mod_Rewrite is Enabled
WooCommerce relies on Apache's
mod_rewrite
for pretty permalinks. If you're using Apache, ensure that:mod_rewrite
is enabled.The
.htaccess
file in the WordPress root directory has the correct rewrite rules. WordPress should automatically generate these, but you can regenerate by re-saving permalinks.
Example .htaccess
for WordPress:
# 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
5. Check for Plugin or Theme Conflicts
Deactivate all plugins except WooCommerce and test the API again.
Switch to a default WordPress theme (like Twenty Twenty-Three) temporarily.
If the API starts working, reactivate plugins/themes one by one to identify the culprit.
6. Ensure HTTPS is Configured Correctly
If your store uses HTTPS, ensure the SSL certificate is valid and properly installed.
Test the API URL in your browser to check for SSL errors.
7. Server Configuration Issues
Check if the hosting server is blocking access to the
/wp-json/
endpoint.Verify the server logs to identify any restrictions or errors.
Contact your hosting provider for assistance with server configurations.