Wordpress How to Fix “nonce_failure” Error in WordPress

SupportFly
5 min readJul 26, 2024

--

You’re not the only one who has seen a “nonce_failure” issue in WordPress. If you don’t know how to manage this WordPress security-related mistake, it might be very annoying. Nonces, which translate to “number used once,” are tokens that WordPress uses to confirm the legitimacy of requests. This adds an extra layer of protection against different kinds of attacks. A “nonce_failure” error indicates that there was a problem with the verification procedure.

What causes “nonce_failure” Error?

The “nonce_failure” error can be triggered by many factors;

Expired Nonce: Nonces has the lifespan of 24 hours by default. This error message appears if you attempt to use a nonce that has expired.

Cache issues: The mismatch can be caused by an older nonce being served by caching plugins or server-side caching.

URL Copying: A nonce may have expired or become invalid if you copy and paste a URL with one and then attempt to use it again.

Multiple Tabs: Working with several tabs may result in nonce problems, particularly when submitting forms or executing commands from separate tabs.

Server time mismatch: Nonce validation problems can happen due to improper server time synchronisation.

Theme or Plugin Conflicts: Errors could arise from custom themes or plugins not treating nonces appropriately.

Steps to fix “nonce_failure” Error

Identify the action causing the issue

Identify which particular feature or activity causes the “nonce_failure” issue. To identify the core reason, carefully go over error messages, server logs, and debugging tools. You can focus your debugging efforts on the relevant code or functionality by using this methodical approach.

Clear browser cache

  • Chrome
  • Go to Settings > Privacy and security > Clear browsing data.
  • Select Cookies and other site data and Cached images and files.
  • Click Clear data.
  • Firefox
  • Go to Options > Privacy & Security > Cookies and Site Data > Clear Data.
  • Select Cookies and Site Data and Cached Web Content.
  • Click Clear.

By clearing the browser cache, you may make sure that any out-of-date nonces are stored in your browser and that new nonces are generated and used.

Clear Wordpress cache

  • W3 total cache
  • Go to Performance > Dashboard.
  • Click Empty All Caches.
  • WP super cache
  • Go to Settings > WP Super Cache.
  • Click Delete Cache.

By clearing the WordPress cache, you can make sure that any outdated nonces are not kept there and that new nonces are generated correctly.

Update Permalinks

  • Go to Settings > Permalinks.
  • Click Save Changes without making any changes.

Any problems with nonces may be fixed by updating permalinks, which can also clear the rewrite cache and refresh the rewrite rules.

Disable Plugins Temporarily

The nonce error may be brought on by a competing plugin. Turn off every plugin for the time being and check if the issue still occurs:

  • Go to Plugins > Plugins Installed.
  • From the bulk actions dropdown, select all of the plugins, then select Deactivate.
  • Verify if the problem has been fixed. If so, find the offending plugin by reactivating each one individually.

You can identify which plugin is causing the conflict by deactivating it. Once found, think about contacting the plugin creator to request a repair or search for a different plugin.

Increase the PHP limit

Change the wp-config.php file to include:

define(‘WP_MEMORY_LIMIT’, ‘256M’);

Increasing the PHP memory limit guarantees WordPress has the resources to carry out all required operations, such as creating and verifying nonces.

Regenerate Nonces

If the nonce problem continues, you may need to produce nonces by including the following code in the ‘functions.php’ section of your theme or in a plugin that is specific to your website:

function regenerate_nonces() {

if (is_user_logged_in()) {

$current_user = wp_get_current_user();

wp_set_auth_cookie($current_user->ID);

}

}

add_action(‘init’, ‘regenerate_nonces’);

Regenerating nonces can fix problems with expired or invalid nonces by ensuring that a new nonce is generated each time the user signs in.

Check for theme issues

Nonce problems could be caused by your theme. Try using Twenty Twenty-One as the default theme to see if it fixes the issue. If it does, there is a problem with your theme; you may need to troubleshoot it more or get in touch with the theme developer for help.

Synchronize server time

Make that the time on your server is synchronized correctly. To maintain precise server time, you can utilize the Network Time Protocol (NTP):

To synchronize time, if you can connect to your server over SSH, execute the following commands:

sudo apt-get install ntp

sudo service ntp start

Debug with WP_DEBUG

Turn on WordPress debugging to learn more about the reason behind the nonce error:

In the wp-config.php file, add or modify the lines that follow:

define(‘WP_DEBUG’, true);

define(‘WP_DEBUG_LOG’, true);

define(‘WP_DEBUG_DISPLAY’, false);

Examine the debug log file at wp-content/debug.log for any nonces-related problem messages. This will enable you to identify the precise problem.

Why choose Supportfly for Wordpress services

At SupportFly, we’re dedicated to using our custom WordPress development services to build dynamic, responsive, and user-friendly WordPress websites.

  • Our skilled team of WordPress developers and web designers collaborates together with you to fully grasp your vision and bring it to life, guaranteeing that your WordPress website functions flawlessly in addition to looking fantastic.
  • Without sacrificing the quality of our services, we offer the most affordable and economical programs. Our team will support you 24/7, no matter what you decide.
  • Our group of incredibly knowledgeable and experienced WordPress developers brings their experience to every project they work on. They make sure your website is developed using cutting-edge techniques and original solutions by staying up to speed with the latest developments in technology.
  • To keep your website up and operating properly, we offer full WordPress after development support and maintenance services. We guarantee that your website is safe, up-to-date and optimized with regular updates and strong security protocols.
  • You don’t have to be worried about confidentiality or privacy when using Supportfly. In order to guarantee the security and privacy of your project details and company information during our partnership, we provide a Non-disclosure Agreement (NDA).

Conclusion

Despite being annoying, the “nonce_failure” problem in WordPress is typically fixable with a few troubleshooting techniques. You can often resolve the issue by cleaning caches, changing permalinks, looking for plugin or theme conflicts, raising the PHP RAM limit, adjusting server time, and turning on debugging. If the issue continues, you might want to look for assistance from a professional developer or the WordPress community.

Ensuring the proper functionality of nonces is crucial for WordPress security and the integrity of your website. You may prevent the “nonce_failure” issue and maintain the functionality of your website by taking the appropriate action.

--

--

SupportFly

SupportFly is an industry-level IT & Server Management Company with proven expertise and technical experts. https://www.supportfly.io