Fixing "The link you followed has expired" in WordPress
Why WordPress shows "The link you followed has expired" when uploading themes, plugins or large files, and how to raise PHP upload and time limits through your host, php.ini or .user.ini.
"The link you followed has expired. Please try again." is one of WordPress's more confusing error messages, because usually nothing has really expired. You'll typically see it after trying to upload a theme, a plugin or a large media file, and the cause is normally a file that's bigger than your server allows.
The message can appear instantly or after a long wait, with no explanation. When a submission exceeds PHP's post_max_size limit, PHP throws away the whole thing, leaving WordPress with an empty form.1 That includes the security token (called a nonce) that WordPress attaches to every admin form. WordPress sees a request with no valid token and shows its standard "this link has expired" message.2
Once you know that, the fix is straightforward: raise the limits or get the file onto the server another way.
Rule out a genuinely expired page
Occasionally the message means what it says. WordPress security tokens are valid for between 12 and 24 hours,3 so if you left an admin page open overnight and then submitted it, the token really has expired.
Reload the page and try again. If the problem persists, especially when uploading a theme or plugin, it's a size limit.
Check your current limits
There are four PHP settings involved:
- upload_max_filesize is the maximum size of a single uploaded file. PHP's own default is 2MB.1
- post_max_size is the maximum size of the whole form submission, including the file. It needs to be larger than
upload_max_filesize. PHP's default is 8MB.1 - max_execution_time is how many seconds a PHP script can run before it's stopped.
- max_input_time is how many seconds PHP will spend receiving the submission. A large file on a slow connection can exceed this.
To see your current values, go to Tools→ Site Health→ Info and expand the Server section, which lists "Upload max filesize", "PHP post max size", "PHP time limit" and "Max input time". The Media Handling section also shows the effective upload size, and Media→ Add New shows "Maximum upload file size" below the upload box.
Compare these with the size of the file you're uploading. Premium themes packaged with demo content can easily be 20MB to 50MB, while many hosts leave the PHP defaults in place.
Raise the limits through your hosting control panel
This is the easiest and safest option, so try it first. Most hosts let you change PHP settings without touching any files.
- cPanel: look for MultiPHP INI Editor or Select PHP Version→ Options.
- Plesk: go to your domain and open PHP Settings.
- Managed WordPress hosts often have a PHP settings page in their own dashboard, or will change limits for you if you ask support.
Before you change anything, make a note of the current values so you can set them back. Sensible values for most sites are:
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
max_input_time = 300
Save, wait a minute, then check Site Health→ Info again to confirm the new values have taken effect.
Use php.ini or .user.ini
If your host doesn't offer a control panel option, you can often set the values in a file in your site's root folder (the same folder as wp-config.php).
On most modern hosting, where PHP runs through FastCGI or PHP-FPM, the file is called .user.ini.4 Create it if it doesn't exist and add the values above. If it already exists, download a copy before editing it. On some older setups the file is php.ini instead. Your host's documentation will say which one they support.
Changes to .user.ini aren't always picked up straight away. PHP only re-reads these files every five minutes by default,4 so wait before deciding it hasn't worked.
Be careful with .htaccess
You'll find plenty of guides suggesting you add lines like php_value upload_max_filesize 64M to .htaccess. This only works when PHP runs as an Apache module,5 which is increasingly rare. On servers using PHP-FPM, LiteSpeed or FastCGI, these lines typically cause an immediate 500 internal server error.
That's why it's worth downloading a copy of .htaccess before you touch it. If the site goes down after adding these lines, upload your saved copy (or remove the lines you added) and the site will come straight back. Then use one of the other methods instead.
Don't bother with WP_MEMORY_LIMIT for this
Increasing WP_MEMORY_LIMIT in wp-config.php is a common suggestion, but memory isn't the problem here. It won't change your upload or post size limits, and it won't fix this error. If you're seeing an "Allowed memory size ... exhausted" error instead, that's a different problem, covered in our memory exhausted guide.
Other layers with their own limits
If you've raised the PHP limits and uploads still fail, something in front of PHP may have its own limit. These usually give a different error, often "413 Request Entity Too Large", but WordPress sometimes reports them as a generic HTTP error.
- Nginx has a
client_max_body_sizesetting that defaults to 1MB and returns a 413 when a request is larger.6 Only your host can change it on shared hosting. - Cloudflare limits uploads to 100MB on its Free and Pro plans.7 Anything larger needs uploading another way.
- Security plugins and firewalls sometimes restrict the size or type of uploaded files. Our 403 forbidden guide covers how to spot a firewall block.
Our guide to fixing WordPress media upload errors covers permissions, firewalls and other upload problems in more detail.
Upload themes and plugins via SFTP instead
If you can't raise the limits, or you just need to get a large theme installed now, skip the browser upload entirely.
- Take a backup, especially if you're replacing an existing version of the theme or plugin.
- Unzip the theme or plugin on your computer.
- Connect to your site with an SFTP client or your host's file manager.
- Upload the unzipped folder to
wp-content/themes/for a theme orwp-content/plugins/for a plugin. - Go to Appearance→ Themes or Plugins in WordPress and activate it.
If you have WP-CLI access, wp plugin install /path/to/plugin.zip --activate or wp theme install /path/to/theme.zip does the same job from the command line.8
Uploading over an existing plugin or theme replaces it without the safety checks WordPress normally runs, so if anything breaks afterwards, our guide to recovering a site broken by an update will help.
For large media files such as videos, consider hosting them on a video platform and embedding them. Large videos served from a WordPress site use a lot of bandwidth and rarely play as smoothly as they would from a dedicated service.
Common questions
Does this error mean my site has been hacked?
No. In most cases it means a file you uploaded was bigger than your server allows, so PHP discarded the submission along with WordPress's security token. Occasionally the token really has expired, because an admin page was left open for many hours before being submitted. Neither is a sign of a security problem with your site.
Is it safe to raise PHP's upload limits?
Generally, yes. Raising upload_max_filesize and post_max_size only changes how large an upload PHP will accept, and the values in this guide are sensible for most sites. Make a note of the old values first so you can set them back, and download a copy of any configuration file before you edit it.
Why does this happen with themes but not plugins?
Usually because the theme's file is bigger. Premium themes packaged with demo content can easily be 20MB to 50MB, well over the limits many hosts leave in place, while many plugins are much smaller. Compare the zip file's size with the "Upload max filesize" shown under Tools → Site Health → Info.
Why do I still get the error after raising the limits?
Usually because the new values haven't taken effect yet, or another layer has its own limit. Check Site Health to confirm the new values, and give a .user.ini change at least five minutes, since that's how often PHP re-reads it by default. If the limits look right, our guide to fixing WordPress media upload errors covers firewalls and server-level restrictions.
Still seeing the error?
If the limits in Site Health look right but the error persists, your host may be applying a limit you can't see, or a firewall may be rejecting the upload, so send them the file size and the time you tried and ask them to check their logs. If you'd rather hand it over, my emergency WordPress support can sort out the limits and get your theme or plugin installed. Many fixes are £50 all in, you'll get a fixed quote before I start and it's no fix, no fee. My WordPress development service also covers upload problems and server configuration.
Description of core php.ini directives, PHP Manual. ↩ ↩ ↩
wp_nonce_ays(), WordPress Code Reference. ↩
.user.ini files, PHP Manual. ↩ ↩
How to change configuration settings, PHP Manual. ↩
Module ngx_http_core_module: client_max_body_size, nginx documentation. ↩
wp plugin install, WP-CLI Commands. ↩