How to fix “415 Unsupported Media Type” Error in WordPress

How to fix “415 Unsupported Media Type” Error in WordPress featured image

Reading Time: 3 min, 36 sec

If you have ever uploaded a file or tried to send a request to your WordPress site and encountered the โ€œ415 Unsupported Media Typeโ€ error, you know how frustrating it can be. As a WordPress developer, I have dealt with this error multiple times, and it usually happens when the server cannot handle the type of file or request you are sending. In this guide, I will explain why it happens and how to fix it.

What is the 415 Unsupported Media Type Error?

The 415 error is an HTTP status code that occurs when a server refuses to accept a request because the media type (MIME type) of the request is not supported. In simpler terms, your WordPress site or server does not recognize the type of file or content you are trying to upload or send.

Best WordPress Hosting

Bluehost is one of the best and secure WordPress hosting provider

In WordPress, this often happens in these situations:

  • Uploading images, PDFs, or other media files that the server does not allow.
  • Making API requests with unsupported Content-Type headers, especially when using plugins or custom REST API endpoints.
  • Sending JSON or XML data that the server is not configured to accept.

When this error occurs, you typically see a message like:

415 Unsupported Media Type
The request entity has a media type which the server or resource does not support.

Common Causes of the 415 Error in WordPress

1. Unsupported File Types:

WordPress has a list of allowed file types for uploads. If you try to upload a file type that is not allowed, some servers may respond with a 415 error.

2. Incorrect Content-Type in API Requests:

When sending requests to the WordPress REST API, the Content-Type header must match the type of data you are sending. For example, if you send JSON, you must use:

Content-Type: application/json

If the server expects a different type, it will return a 415 error.

3. Server or Hosting Restrictions

Some hosting environments block certain file types or do not support specific Content-Type headers. Security modules like ModSecurity or custom server rules can trigger this error.

4. Plugin or Theme Conflicts

Certain plugins or themes may improperly handle uploads or API requests, causing the server to reject the request.

How to Fix the 415 Unsupported Media Type Error

Here are the practical steps I follow as a WordPress developer to fix this issue:

1. Check the File Type You Are Uploading

Make sure the file type is supported by WordPress. Common allowed types include: .jpg, .jpeg, .png, .gif, .pdf, .docx, .pptx.

If you need to allow a custom file type, you can add this to your functions.php:

function allow_custom_upload_types($mimes) {
    $mimes['svg'] = 'image/svg+xml'; // Example: Allow SVG files
    return $mimes;
}
add_filter('upload_mimes', 'allow_custom_upload_types');

2. Set the Correct Content-Type in API Requests

When using REST API or custom requests, make sure your request headers match the data you are sending:

Content-Type: application/json

For XML data, use:

Content-Type: application/json

3. Check Server or Hosting Restrictions

Some hosting providers block certain file types or MIME types. Contact your host or check your server configuration to allow the file type or header you need.

4. Disable Conflicting Plugins or Themes

If the issue started after installing a plugin or theme, try disabling them temporarily to identify the cause. Some security or REST API plugins may enforce strict MIME rules that lead to 415 errors.

5. Update WordPress, Plugins, and Themes

Outdated WordPress core, plugins, or themes can cause compatibility issues with file handling and REST API requests. Keeping everything updated often resolves these errors.

6. Use a File Type Plugin for Advanced Control

If you frequently need to upload unusual file types, plugins like WP Extra File Types allow you to safely enable additional MIME types without editing code.

Conclusion

The 415 Unsupported Media Type error in WordPress is usually related to file types, MIME types, or incorrect headers in requests. By checking the file type, setting the correct content headers, reviewing hosting restrictions, and troubleshooting plugins, you can resolve the issue quickly.

From my experience, most 415 errors occur when the server rejects uploads or REST API requests due to mismatched content types. Implementing the fixes above ensures smooth uploads and API interactions on your WordPress site.

Deepanker profile image

Written by Deepanker

Deepanker Verma is an experienced WordPress developer who has been working on WordPress for more than 12 years. On TheWPGuides, he writes about WordPress, WordPress development, and WordPress plugins.

Leave a Reply

Your email address will not be published. Required fields are marked *

Need a Hand with Your WordPress Site?

Don't let technical issues slow you down. Our professional WordPress maintenance service handles updates, security, and performance optimization so you can focus on what you do best: creating content.

Learn More About Our Services