in

How to Fix the "406 Not Acceptable" Error on Your WordPress Site: An In-Depth Troubleshooting Guide

default image

As an avid WordPress user, I know how disruptive and confusing error messages can be. The "406 Not Acceptable" error is one of those obscure issues that can make your site seem broken when it really isn‘t.

In this comprehensive guide, we‘ll demystify the 406 error, analyze why it occurs, and walk through all the steps you need to resolve it. I‘ll also share my tips as a experienced developer on how to proactively avoid these types of errors in the future.

By the end, you‘ll have the confidence to quickly troubleshoot and fix the next 406 error or other HTTP status code issue that pops up!

What Exactly is a "406 Not Acceptable" Error?

Let‘s start by understanding what the 406 error code means in plain English.

The 406 status code indicates that the server cannot provide a response that meets the criteria sent by the client in the request. Specifically, the headers – like Accept, Accept-Charset, Accept-Language, etc. – contain specifications that the server is unable to satisfy.

As a quick example, imagine you go to a Mexican restaurant and request a pizza. The restaurant staff would be confused and unable to give you a pizza, since that‘s not on their menu. The 406 error is basically the restaurant saying "Sorry, your request for pizza is not acceptable here, we don‘t have the capabilities to give you that."

In website terms, this error happens because of a mismatch between what the browser asks for and what the server can provide. When this incompatibility occurs, the user simply sees a generic "406 Not Acceptable" page rather than the normal site content.

To the average visitor, all they know is your site is broken. But as the website owner, you have the power to fix this! First we have to explore why this error happens in the first place.

The Most Common Causes of 406 Errors in WordPress

Based on my experience tracking down 406 errors for clients, here are the most frequent culprits:

1. Mismatched Content Types

The browser sends an Accept header that specifies the format it wants, like text/html for an HTML document. If the server tries to send something incompatible with that request, like application/json, the 406 error will appear.

Example:

  • Browser requests HTML page
  • Server responds with JSON data
  • This causes a content type mismatch

This is one of the most common trigger points for 406 errors.

2. Problems with the Accept Header

As mentioned above, the Accept header contains the supported media types. Issues can occur when:

  • The Accept header includes types the server doesn‘t recognize
  • It‘s formatted incorrectly
  • It‘s missing altogether

This leads to the server being unable to meet the specifications in the header and throwing a 406 error.

3. Conflicting Language Preferences

Browsers communicate their preferred language via the Accept-Language header. For instance, this might specify en-US for English US.

If the server can‘t provide a translation matching any of the listed languages, the 406 status code results.

This happens when:

  • The server doesn‘t have content for the requested languages
  • There‘s a mismatch between requested and available languages

4. Character Set Incompatibilities

The Accept-Charset header indicates allowed character sets like UTF-8 or ISO-8859-1. If none of these match what the server can deliver, the 406 appears.

Why does this occur?

  • The server may not support the character sets listed
  • There‘s an incompatibility between requested and available character sets

5. Overly Strict Mod_Security Rules

Mod_security is a popular open source web application firewall for Apache servers. It uses a set of rules to detect and block potential attacks.

Sometimes, these rules end up being too restrictive. Legitimate requests get blocked, producing 406 errors instead of the real content.

6. Plugin or Theme Conflicts

Incompatible plugins or themes are a common source of 406 errors in WordPress. If plugins have conflicts with each other or with the theme, the site breaks.

Debugging these types of conflicts between elements like JavaScript, CSS, etc. can be tricky.

7. Server Configuration Issues

If the web server is configured incorrectly, it may not properly support the necessary MIME types, character encodings, content negotiation, etc. This prevents it from responding correctly.

Ideally the server should be optimized specifically for WordPress requirements. Misconfigurations are a leading cause of 406 and other errors.

8. Caching Problems

Content Delivery Networks (CDNs) and caching plugins can improve performance. However, they also run the risk of serving outdated, corrupted, or invalidated cached content, potentially causing 406 errors.

This happens when the cached content no longer matches the real updated site content. Clearing the problematic caches resolves it.

Now that you know what typically causes those pesky 406 errors, let‘s go through the steps to diagnose and fix them.

An 8-Step Game Plan for Troubleshooting 406 Errors

Pinpointing the origin of a 406 error can be tedious and time consuming, even for experienced developers.

Based on past incidents, I‘ve put together a methodical troubleshooting game plan to streamline the process:

Step 1: Reproduce the Error

This may sound obvious, but the first step is reliably reproducing the 406 error.

The key is determining:

  • What pages trigger the 406 error consistently
  • Under what conditions it occurs – certain browsers? Mobile vs desktop?

Understanding the pattern helps narrow the focus for the next steps.

Step 2: Review the Request Headers

The request headers provide clues about what the client is asking for. Use the Network tab in browser Developer Tools to inspect them.

Check that the Accept header:

  • Lists only supported media types
  • Doesn‘t contain wrong or conflicting values
  • Includes proper language and character set preferences

This can reveal what exactly the browser is requesting that the server can‘t provide.

Step 3: See If It‘s Browser or Device Specific

Does the 406 error happen on certain browsers or devices and not others?

To test this:

  • Try to access the affected pages in different desktop, mobile and tablet browsers – Chrome, Firefox, Safari, etc.
  • Check if a specific browser, OS, or device triggers the error consistently
  • If so, we know it‘s an isolated client-side issue

Many 406 errors are browser or device-dependent, an important clue.

Step 4: Switch to a Default Theme

Switching to a default WordPress theme like Twenty Twenty-One can instantly reveal if your custom theme causes the 406 error.

To do this:

  • Back up your current theme
  • Activate the Twenty Twenty-One theme
  • Test if the error still occurs
  • If it disappears, your original theme likely has conflicts

This theme switch test takes under 5 minutes and can pinpoint theme-related 406 errors quickly.

Step 5: Disable All Plugins

Like themes, incompatible plugins are a leading cause of 406 errors.

To test if a plugin is responsible:

  • Back up your plugin folder
  • Disable all plugins
  • Check if the 406 error still appears
  • If it‘s gone, re-enable plugins one by one to find the problematic plugin

Tedious but effective for isolating plugin-related 406 errors.

Step 6: Inspect Server Error Logs

Many 406 errors arise from server-side issues. Your hosting provider‘s error logs can offer clues.

Check the logs for:

  • Repeated 406 errors
  • Errors related to content types, encodings, etc.
  • Other unusual activity around the times of the errors

Logs help pinpoint server configuration problems contributing to 406 errors.

Step 7: Review Site Changes and Updates

Think back to when the 406 error first appeared – did anything change around that time?

  • New plugins, themes, or WordPress updates?
  • Server configuration changes?
  • New CDN or caching settings?

Understanding what altered near the time the error emerged leads to the culprit.

Step 8: Ask Your Hosting Provider for Assistance

If you still can‘t resolve the 406 error, don‘t go it alone. Your hosting provider‘s support team has the server access and logs to spot misconfigured settings causing 406 errors.

Explain exactly when the error appears and what troubleshooting you‘ve tried. They should be able to pinpoint any server-side factors.

This 8-step approach allows you to systematically isolate the source of those obscure 406 errors. Let‘s look at specific solutions once you‘ve identified the cause.

Custom Fixes Depending on the Trigger

Now that we‘ve gone through strategically troubleshooting the error, we can drill down into targeted solutions for each root cause.

1. Fixing Mismatched Content Types

If the 406 error stems from incompatible content types between the request and response, we need to align them.

This may involve:

  • Modifying the server configuration to properly map file extensions like .html to the right MIME types
  • Adjusting WordPress to use the supported content types
  • Altering the Accept header to request compatible content types

Coordinating the formats between the client and server resolves these 406 mismatches.

2. Correcting Invalid Accept Headers

If the Accept header is missing or incorrect, we need to submit a valid header:

  • Make sure the header only includes types the server can respond with
  • Remove any unsupported or invalid media types
  • Resend a corrected Accept header that matches the available formats

Again this ensures the client asks for content types the server can realistically provide.

3. Updating Language and Charset Headers

If the error relates to unsupported languages or character encodings, updating the request headers fixes it:

  • Check which languages/charsets are accessible to the server
  • Update the Accept-Language and Accept-Charset headers accordingly
  • Only include languages and encodings that the server can deliver

This synchronization resolves the incompatibility causing those 406 errors.

4. Adjusting Mod_Security Rules

As mentioned earlier, the Mod_Security web application firewall can sometimes block legitimate requests.

To prevent this:

  • Work with your hosting provider to identify and adjust the problematic rules
  • Consider disabling specific rule sections temporarily just to test
  • Whitelist your site‘s IP address or request patterns in Mod_Security

Tweaking the rules restores normal operation while maintaining security.

5. Switching Incompatible Themes or Plugins

If a certain theme or plugin conflicts with the site, switching away from it stops the 406 errors.

  • For themes, revert back to your previous theme or choose a new compatible one
  • For plugins, find an alternative plugin that provides the same functionality without conflicts

Choosing compatible themes and plugins is key to preventing recurring 406 errors.

6. Correcting Server Configuration Issues

Improperly configured servers account for many 406 errors. Work with your hosting provider to:

  • Review and optimize the MIME types, character encodings, and other relevant settings
  • Update the configurations based on WordPress best practices
  • Test the adjustments to confirm they resolve the 406 error

Properly configuring the server to handle your WordPress site‘s needs is crucial.

7. Clearing Caches

For caching-related 406 errors, flushing the stale caches fixes it:

  • Clear your WordPress caches via plugin or manually
  • Work with your hosting provider to purge server-side caches like Varnish
  • Empty any CDN caches

Fresh, uncorrupted caches prevent 406 errors.

With the right resolution for each trigger, you can get your site back up and running smoothly. But prevention is also key…

Preventing 406 Errors in the Future

Troubleshooting 406 errors can be a pain. While you can‘t avoid them completely, smart preventive measures go a long way.

Here are my top tips as a WordPress developer for avoiding 406 errors proactively:

  • Keep software updated – Outdated WordPress, themes and plugins cause compatibility issues and bugs that can trigger 406 errors. Regular updates are #1 prevention.

  • Install plugins/themes cautiously – Don‘t just install any plugin or theme. Research them first, read the reviews and test for compatibility issues. Prevention begins at installation.

  • Use a content delivery network (CDN) – Distributing static assets globally via a CDN reduces server workload and minimizes errors. Amazon CloudFront and Cloudflare are good options.

  • Enable server-side and WordPress caching – Caching reduces requests to the origin server and improves performance. But keep caches cleared!

  • Monitor server and site logs – Logs provide visibility into recurring errors and anomalies. Stay vigilant so you can catch 406 errors early.

  • Perform security audits – Hacks that slip through vulnerabilities can potentially cause 406 and other errors. Audits help lock down your site.

  • Test extensively before site changes – Major updates, new plugins, UI changes, etc. should be thoroughly tested beforehand across browsers. Catch potential conflicts.

  • Optimize images and assets – Minify and compress images, CSS, JS and HTML to reduce server workload and deliver assets efficiently.

Following these best practices helps avoid many of the common pitfalls that lead to those frustrating 406 errors.

In Closing

Hopefully this guide has given you a comprehensive understanding of what causes the confusing "406 Not Acceptable" error, as well as systematic troubleshooting steps and preventive measures.

The key lessons are:

  • The 406 error stems from an incompatibility between the client request headers and the server response.

  • Typical causes include mismatched content types, plugin/theme conflicts, server misconfigurations, and caching issues.

  • Methodically troubleshoot using the 8-step process outlined to isolate the root cause.

  • Address the specific issue based on the triggering factor, like updating incompatible software or fixing server settings.

  • Proactively keep software updated, monitor logs, secure your site, and test extensively to avoid 406 errors in the future.

Don‘t let obscure HTTP status codes like the 406 error slow down your WordPress site! Now you‘re armed with a clear roadmap to troubleshoot precisely and get your site back up and running quickly.

Let me know if you have any other questions!

AlexisKestler

Written by Alexis Kestler

A female web designer and programmer - Now is a 36-year IT professional with over 15 years of experience living in NorCal. I enjoy keeping my feet wet in the world of technology through reading, working, and researching topics that pique my interest.