WP Tuts Hub

Browse

  • Home
  • Categories
    • WordPress & AI
    • WordPress Security
    • WordPress Troubleshooting
    • WordPress Tips and Tricks
    • Series Tutorials
  • WordPress Tools
    • Inside WordPress
    • All tools
    • Error decoder
    • Redirect tester
    • URL replace
    • wp-config helper
    • Plugin Suggestor (AI)
    • Snippet Studio
    • Permalinks builder
    • Conflict triage
    • Log decoder
    • More free tools
  • My Plugins
  • Contact Me
  • About WP Tuts Hub
Home/WordPress Troubleshooting/Fix ‘The link you followed has expired’ in WordPress
WordPress Troubleshooting
By Md. Zubaer Ahammed December 3, 2026

Fix ‘The link you followed has expired’ in WordPress

  • ModSecurity
  • Nonces
  • php.ini
  • post_max_size
  • WP-CLI
Fix ‘The link you followed has expired’ in WordPress

In WordPress, “The link you followed has expired” is a nonce failure, not a broken URL. check_admin_referer() calls wp_nonce_ays() to render that page whenever the nonce is missing or fails wp_verify_nonce(), and it fires from the plugin installer, the theme uploader, the media library and most settings screens. Three things cause it: a POST body larger than post_max_size that PHP discards before WordPress can read the _wpnonce field, a nonce that aged out while an admin tab sat open, or a ModSecurity rule that killed the request before PHP started. The fixes do not overlap, so identify the cause before editing a config file.

What the nonce check is actually testing

A nonce is a hash of the action name, the user ID, the session token from the logged-in cookie, and a time tick. The tick comes from wp_nonce_tick():

$nonce_life = apply_filters( 'nonce_life', DAY_IN_SECONDS, $action );
return ceil( time() / ( $nonce_life / 2 ) );

Verification accepts the current tick and the one before it, so a nonce lives somewhere between 12 and 24 hours. That range is why a form left open overnight fails while the same form submitted after ten minutes works. The session token matters just as much: log out everywhere, let the session expire, or change the keys and salts in wp-config.php during a migration, and every nonce on an already-rendered page is dead regardless of its age.

The upload case is different and easier to misread. PHP compares the request’s Content-Length with post_max_size. If the body is bigger, PHP throws away $_POST and $_FILES, writes a POST Content-Length of N bytes exceeds the limit of N bytes warning to the PHP error log, and hands WordPress an empty request. The installer looks for _wpnonce, finds nothing, and shows the expired-link page. A 90 MB plugin zip on a host capped at 64M produces a nonce error, not a size error.

The page WordPress renders when the installer nonce does not verify (test site: WordPress 7.1.3, PHP 8.2)
The page WordPress renders when the installer nonce does not verify (test site: WordPress 7.1.3, PHP 8.2)

Three fixes, and the evidence that picks one

Raising the PHP limits fits when small plugins install fine and large ones fail, or when media uploads break above a certain size. The evidence is the zip size next to the values from ini_get().

Extending the nonce window fits when the same form succeeds after a page refresh, when failures cluster after lunch or the next morning, or when the person reporting it is on a slow connection filling in a long form. The evidence is timing, plus a fresh page load fixing it.

Relaxing a ModSecurity rule fits when the request fails in under a second, when the response page has no WordPress markup, and when the server log names a rule ID. Nothing you change in PHP will help there.

Start with the limits. It is the most common cause of the installer variant, it is a config change rather than a code change, and if the limits were already fine you have lost five minutes. The nonce filter is a small companion for the long-tab case, not a substitute for correct limits. ModSecurity is a conversation with the host, and you want log evidence before you have it.

Advertisement

Read the real limits before you change them

Do not trust the php.ini you edited. Ask the PHP that serves the site what it ended up with. The quickest place is Tools > Site Health > Info > Server, which lists PHP SAPI, PHP max input variables, PHP time limit, PHP memory limit, Max input time, Upload max filesize and PHP post max size as the web server sees them. The Media Handling panel on the same screen shows the max effective file size WordPress works out from them.

WP-CLI prints the same directives in one go:

wp eval '
$keys = array( "upload_max_filesize", "post_max_size", "memory_limit", "max_execution_time", "max_input_vars", "max_file_uploads" );
foreach ( $keys as $key ) {
    printf( "%-20s %s\n", $key, ini_get( $key ) );
}
printf( "%-20s %s\n", "wp_max_upload_size", size_format( wp_max_upload_size() ) );
'

One warning before you rely on that output. WP-CLI runs the command-line PHP, which on many servers loads a different php.ini from PHP-FPM or mod_php and never reads .user.ini. A memory_limit of -1 and a max_execution_time of 0, as in the output below, are command-line defaults. When WP-CLI and Site Health disagree, Site Health is the one describing the upload that failed.

wp_max_upload_size() returns the smaller of upload_max_filesize and post_max_size, which is the number the media library and the installer actually work with. If post_max_size is the smaller one, every upload above it fails with the nonce message rather than a size message. If the values differ from the file you edited, you are looking at the wrong pool: a per-site PHP-FPM pool, a host control panel override, or a .user.ini that has not been re-read yet.

The limits WP-CLI reports, plus the upload ceiling WordPress calculates from them (test site: WordPress 7.1.3, PHP 8.2):

upload_max_filesize  2M
post_max_size        8M
memory_limit         -1
max_execution_time   0
max_input_vars       1000
max_file_uploads     20
wp_max_upload_size   2 MB

Set the limits in php.ini or .user.ini

; php.ini, or .user.ini in the WordPress root
upload_max_filesize = 64M
post_max_size = 80M
memory_limit = 256M
max_execution_time = 300
max_input_time = 300
max_input_vars = 5000
max_file_uploads = 20

post_max_size sits above upload_max_filesize on purpose. A multipart body carries the file plus form fields, boundaries and headers, so a 64M file needs a body limit with room to spare. Setting both to 64M leaves you failing on files a few kilobytes under the cap.

memory_limit matters because unzipping a plugin or resizing an image happens in PHP memory, and max_execution_time matters on slow shared storage where a 40 MB theme takes longer than 30 seconds to unpack. max_input_vars is the quiet one: a menu or widget screen with more fields than the limit gets its POST truncated. PHP drops every field past the limit without an error, so settings quietly fail to save, and if the nonce field falls after the cut you get the same expired-link page. If the failure happens on a big settings form rather than an upload, look there first. The upload limit walkthrough covers the same values from the media library side.

Which file to edit depends on the SAPI. .user.ini is read by PHP-FPM and CGI builds, is cached for user_ini.cache_ttl (300 seconds by default), and applies to the directory it sits in and everything below it, so the WordPress root covers wp-admin too. A real php.ini change needs a PHP-FPM or Apache restart. Neither file can be replaced by ini_set() at runtime for the upload and POST limits, because upload_max_filesize, post_max_size and max_input_vars are PHP_INI_PERDIR and are locked before your code runs.

The .htaccess version, and when it breaks your site

<IfModule mod_php.c>
	php_value upload_max_filesize 64M
	php_value post_max_size 80M
	php_value memory_limit 256M
	php_value max_execution_time 300
	php_value max_input_vars 5000
</IfModule>

This only works under mod_php. On PHP-FPM or CGI, php_value is not a valid directive and Apache returns a 500 for the whole site, which is a much worse afternoon than the one you started with. The <IfModule> guard prevents that, and on PHP 7.4 the module name is mod_php7.c rather than mod_php.c. If you are unsure which SAPI you are on, read the PHP SAPI row under Tools > Site Health > Info > Server. WP-CLI cannot tell you, because it always reports cli. Skip this block entirely unless that row says apache2handler.

Extend the nonce window for upload screens only

If the limits are correct and the failure still happens on a tab that has been open since yesterday, the nonce aged out. You could tell people to refresh, and often that is the right answer. When it keeps happening on a slow connection or a long installer form, widen the window for the actions that need it and leave everything else alone:

<?php
/**
 * Plugin Name: Longer Nonces for Upload Screens
 * Description: Doubles the nonce life for the plugin, theme and media upload forms.
 */

add_filter(
	'nonce_life',
	function ( $life, $action = '' ) {
		$slow_actions = array(
			'plugin-upload',
			'theme-upload',
			'media-form',
		);

		if ( in_array( $action, $slow_actions, true ) ) {
			return 2 * DAY_IN_SECONDS;
		}

		return $life;
	},
	10,
	2
);

The second argument only exists from WordPress 6.1, which is why the callback defaults $action to an empty string. On an older install nothing matches and the filter is a no-op, so the file is safe to leave in place across an upgrade. Drop it in wp-content/mu-plugins/ so it loads without an activation step.

Doubling the life doubles the replay window for a captured nonce URL, which is the whole point of the mechanism. Keep the list short, keep the value modest, and do not set it to a week because one person had a slow afternoon. If you want the background on what a nonce does and does not protect, the nonce and capability checks write-up goes through it from the REST side.

One case no filter fixes: several web servers behind a load balancer whose wp-config.php files carry different keys and salts. A nonce created on one server is hashed with a different NONCE_KEY on the next, so it never verifies. The symptom is a failure that comes and goes on fresh pages, not after a delay. Copy the same keys and salts to every server.

The mu-plugin doubles the nonce life for upload actions and leaves other actions at 24 hours (test site: WordPress 7.1.3, PHP 8.2):

plugin-upload: 172800
edit-post: 86400

ModSecurity leaves a different fingerprint

When a WAF rule blocks the request, PHP never runs. The response is a 403 with a host-branded page, or a bare “Not Acceptable”, and the WordPress debug log stays empty because no code executed. The server error log is where the answer is. The path below is the Debian and Ubuntu default; on other systems it is often /var/log/httpd/error_log:

grep -i "ModSecurity" /var/log/apache2/error.log | tail -n 20

You are looking for a line containing Access denied with code 403 and a rule ID such as [id "949110"]. With the ID in hand, ask the host to exclude that rule for /wp-admin/, which is the clean fix and the only one available on most managed plans. Removing a rule yourself with SecRuleRemoveById in .htaccess only works when the host built ModSecurity with .htaccess support, and most leave that out on purpose. Turning the engine off site-wide to install one plugin is not a trade worth making.

Uploads that fail only for particular files, a plugin whose zip contains a path the rule dislikes, are the usual shape of this. If the same size uploads succeed from a different plugin, the limits are not your problem.

My tip · Md. Zubaer Ahammed

Before changing anything, search the PHP error log for POST Content-Length. PHP writes that warning each time a request is larger than post_max_size, so one matching line at the time of the failed upload tells you the body was dropped and the nonce had not expired.

Confirm the fix with the same upload that failed

Re-run the exact upload, not a smaller one. Then check the access log for the POST and its status: a 200 or 302 means PHP handled it, a 403 means something in front of PHP is still blocking it, and a 200 with the expired page means the nonce is still missing from the body. Reloading the Site Health Server panel tells you whether the new values took effect or whether you are still editing a file the running pool ignores.

If media uploads fail with a different message, usually “HTTP error” or a generic failure after the progress bar, that is a separate problem with its own causes, and the HTTP error upload fix is the better place to start.

For the next occurrence, hook wp_verify_nonce_failed, which fires inside wp_verify_nonce() with the nonce, the action and the user, and write the action plus $_SERVER['REQUEST_URI'] to the debug log. After a week you will know which screen is failing and whether it is one action or all of them, which is the difference between a stale tab and a broken session setup. The hook stays silent when the POST body was dropped, because check_admin_referer() never calls wp_verify_nonce() without a nonce to check. An expired-link report with no matching log line points back at post_max_size.

Share this:

  • Share on X (Opens in new window) X
  • Share on Facebook (Opens in new window) Facebook
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on WhatsApp (Opens in new window) WhatsApp
  • Share on Reddit (Opens in new window) Reddit
  • Email a link to a friend (Opens in new window) Email

Related

Advertisement
Previous Article Laravel Now Runs on Rust and Go. Will WordPress Follow?

About the author

Md. Zubaer Ahammed

Md. Zubaer Ahammed

Md. Zubaer Ahammed is a senior full-stack developer building learning platforms and modern web systems with WordPress, Laravel, Python/Django, Vue, and React. More at https://zubaer.com/.

I also build WordPress plugins, including ZubFeat AI Featured Image and ZubQuant. See my plugins and services →

Related Posts

  • Fix WordPress 403 Forbidden Error: A Systematic Audit Checklist Fix WordPress 403 Forbidden Error: An Audit Checklist
  • Fix ‘Updating Failed’ Invalid JSON in WordPress Fix ‘Updating Failed’ Invalid JSON in WordPress
WP Tuts Hub

WordPress tutorials, themes, and plugins — written for builders.

Topics

  • WordPress & AI
  • WordPress Security
  • WordPress Development
  • WordPress Troubleshooting
  • WordPress Tips and Tricks

Resources

  • WordPress Tools
  • How WordPress Works
  • My Plugins
  • Portfolio
  • About WP Tuts Hub
  • Contact Me

© 2026 WP Tuts Hub · Md. Zubaer Ahammed

Privacy Policy Terms of Use