Why WordPress Says "The Link You Followed Has Expired"
Fix the WordPress expired-link error during uploads. See how PHP post_max_size and upload_max_filesize cause it, check your limits, and choose the right fix.
WordPress usually shows “The link you followed has expired” because the upload was larger than PHP’s post_max_size limit. PHP discards the whole request, WordPress’s security nonce check fails, and WordPress reports that failure in place of a file-size error.
You drag a 70 MB premium theme zip onto the uploader, watch the progress bar finish, and get a page about an expired link. The message suggests a stale session, but the real problem is a server limit.
This article explains why PHP produces this misleading message, which three settings control it, how to read your current limits, and which fix works for the way your server runs PHP.
Key Takeaways
- When a request exceeds
post_max_size, PHP leaves$_POSTand$_FILESempty, so WordPress’s nonce check fails and it shows “The link you followed has expired.” upload_max_filesizeandpost_max_sizeareINI_PERDIRsettings, soini_set()in functions.php or a snippet plugin cannot change them.php_valuelines in .htaccess only work when PHP runs as an Apache module. Under PHP-FPM, use .user.ini or your host’s PHP settings instead.WP_MEMORY_LIMITin wp-config.php controls memory, not the maximum upload size.- Uploading an unzipped theme or plugin folder over SFTP avoids PHP’s upload limits entirely.
Why the Link You Followed Has Expired After an Upload
When a request body is larger than post_max_size, PHP leaves both $_POST and $_FILES empty, which the PHP manual’s post_max_size entry documents. The nonce WordPress embedded in the upload form travels in that discarded data, so WordPress cannot tell an oversized upload apart from a forged or stale submission. It falls back to wp_nonce_ays(), whose default output is “The link you followed has expired.” with a 403 status.
“The link you followed has expired” can also appear without any upload. If an admin page stays open long enough, its nonce expires, and submitting the form produces the same text. Reloading the page issues a fresh nonce and fixes it.
The Three PHP Settings Behind the Error
Three PHP directives control large WordPress uploads: upload_max_filesize, post_max_size and max_execution_time. Two of them cause the expired-link error:
| Directive | What it limits | Changeable with ini_set()? |
|---|---|---|
upload_max_filesize | Each uploaded file | No (INI_PERDIR) |
post_max_size | The entire request body | No (INI_PERDIR) |
max_execution_time | Script run time in seconds | Yes |
post_max_size should be set slightly higher than upload_max_filesize, because the request also carries form fields and multipart boundaries. PHP’s documentation says that to upload large files, post_max_size must be larger than upload_max_filesize. The same page lists both size directives as INI_PERDIR. Per the PHP manual on modes, INI_PERDIR settings can be set in php.ini, .htaccess, httpd.conf or .user.ini, but not from a running script.
Because both size directives are INI_PERDIR, snippets that call ini_set() for them in functions.php or a snippet plugin cannot work. Even setting the changeable-mode rule aside, PHP has already accepted or discarded the request body before any WordPress code runs. An @ in front of the call only hides the warning. Some tutorials also use upload_max_size, which is not a PHP directive at all.
A file that is over upload_max_filesize but under post_max_size fails differently. PHP still delivers the form data, so WordPress can report a size-specific upload error. A timeout from max_execution_time also looks different: you usually get a fatal error about the maximum execution time or a gateway timeout, not the expired-link message.
How to Check Your Current Upload Limits
WordPress shows the effective limit in two places in the admin:
- Media > Add Media File shows “Maximum upload file size” below the drop zone.
- Tools > Site Health > Info has a Server section that lists PHP’s upload and post limits and the execution time. The Media Handling section shows the effective maximum upload size.
To find out which file to edit, you also need to know how PHP runs. Put this temporary file in the web root, load it in a browser, then delete it, because it exposes server details:
<?php
echo 'SAPI: ' . PHP_SAPI . "\n";
echo 'Loaded php.ini: ' . (php_ini_loaded_file() ?: 'none') . "\n";
echo 'user_ini.filename: ' . ini_get('user_ini.filename') . "\n";
foreach (['upload_max_filesize', 'post_max_size', 'max_execution_time'] as $k) {
echo $k . ': ' . ini_get($k) . "\n";
}
What the SAPI value means:
apache2handler: PHP runs as an Apache module, so you can use .htaccess or php.ini.fpm-fcgiorcgi-fcgi: use .user.ini or your host’s panel, and neverphp_value.
How to Raise PHP Upload Limits, Easiest First
Every method below raises the upload limits by changing PHP’s configuration before the request is parsed. That is the only place these limits can be changed. Some hosts disable one or more of these methods, so if a change doesn’t show up in Site Health, try the next one or ask the host.
1. Hosting Control Panel
Most managed and shared hosts offer a PHP settings or “PHP options” screen. Changes made there apply at the server level and need no file editing. Try this first.
2. php.ini or .user.ini
On a VPS, edit the loaded php.ini shown by the diagnostic file and restart PHP. On CGI/FastCGI setups, including PHP-FPM, create a .user.ini file in the WordPress root. Both files use the same syntax:
; Example values — adjust to your largest expected upload
upload_max_filesize = 64M
post_max_size = 128M
max_execution_time = 300
Always include the unit suffix. PHP reads a bare integer as bytes, so 128 means 128 bytes.
The PHP manual’s .user.ini page explains that PHP looks for the file in the requested script’s directory and in each parent directory up to the document root. PHP rereads .user.ini every user_ini.cache_ttl seconds, which defaults to 300. A .user.ini change can therefore take up to five minutes to apply. user_ini.cache_ttl is a system-level setting, so you can’t shorten it from .user.ini.
3. .htaccess (Apache With mod_php Only)
# Example values — Apache with PHP as a module only
php_value upload_max_filesize 64M
php_value post_max_size 128M
php_value max_execution_time 300
PHP’s documentation on changing configuration settings describes php_value as a directive for PHP running as an Apache module. Under PHP-FPM, Apache doesn’t recognise the directive. Depending on the setup, it either ignores the line or responds with a 500 Internal Server Error. Nginx doesn’t read .htaccess at all.
What Doesn’t Work: wp-config.php
wp-config.php cannot raise the upload limit. WP_MEMORY_LIMIT sets how much memory WordPress requests from PHP and has no effect on upload size. If a config change leaves you with a blank page, see the WordPress white screen of death fix.
Workaround: Upload the Theme or Plugin by SFTP
You can skip PHP’s upload limits entirely by uploading the unzipped theme or plugin folder to wp-content/themes or wp-content/plugins over SFTP. The files never pass through a PHP request. Unzip locally, then:
sftp user@example.com
put -r my-theme /path/to/wp-content/themes/
The remote path varies by host. Once the folder is in place, activate it under Appearance > Themes or Plugins. Use SFTP rather than plain FTP so your credentials aren’t sent in cleartext. OpenReplay’s guide on how to secure a WordPress site covers that and other access hardening.
Fixing the Real Cause
“The link you followed has expired” usually means the upload was bigger than post_max_size, not that a session expired. Run the diagnostic file to see how PHP runs on your server. Then raise upload_max_filesize and post_max_size in the place that matches it: your host’s panel, php.ini or .user.ini, or .htaccess only under mod_php. Check the new values in Site Health before you retry the upload.
FAQs
How long does a WordPress nonce stay valid before it expires?
A WordPress nonce stays valid for between 12 and 24 hours by default. The nonce_life filter defaults to DAY_IN_SECONDS (86,400 seconds), and WordPress splits that into two 12-hour ticks, accepting the current and previous tick. An admin form left open overnight can therefore fail with the expired-link message. Developers can change the lifespan with the nonce_life filter, but shortening it globally makes these errors more frequent.
Why do I get a 413 Request Entity Too Large error instead of the expired-link message?
A 413 error means Nginx rejected the upload before PHP saw it. Nginx's client_max_body_size directive defaults to 1m, and any request body above it is refused immediately. Raise it in the http, server or location block that handles wp-admin, then reload Nginx. PHP's upload_max_filesize and post_max_size still need raising afterwards, and a CDN or reverse proxy in front of the site can enforce its own limit.
Why does WordPress show a lower maximum upload size than my upload_max_filesize value?
WordPress shows the smaller of upload_max_filesize and post_max_size as the maximum upload size, through its wp_max_upload_size() function. If upload_max_filesize is 256M but post_max_size is 64M, the effective limit is 64M. Raising only one directive leaves the displayed limit unchanged. Set post_max_size slightly above upload_max_filesize, then confirm both values in the Server section of Site Health.
Can WP-CLI install a theme or plugin zip without hitting PHP upload limits?
Yes. WP-CLI runs on the server's command line, so the zip never travels through a browser upload and post_max_size does not apply. Copy the zip to the server over SFTP, then run wp theme install /path/to/theme.zip --activate or wp plugin install /path/to/plugin.zip --activate. Both commands accept a WordPress.org slug, a local zip path or a remote zip URL. This requires SSH access.
Gain Debugging Superpowers
Unleash the power of session replay to reproduce bugs, track slowdowns and uncover frustrations in your app. Get complete visibility into your frontend with OpenReplay — the most advanced open-source session replay tool for developers.
Star on GitHub12k