Invalid or expired key
Problem
Users click the password reset link in their email but see an error message about an invalid or expired key.
Symptoms
- Error message: "Invalid or expired key"
- Error message: "The key is no longer valid"
- Reset link doesn't work when clicked
- User is redirected to error page
Common causes
Key has expired
WordPress password reset keys expire after 24 hours by default.
Key already used
Reset keys can only be used once. After successful password reset, the key becomes invalid.
URL parameters modified
User may have accidentally modified the reset link URL.
Database issues
Database connection problems or corrupted user meta data.
Caching issues
Page caching may serve stale content with old error messages.
Solutions
Solution 1: Request new reset link
The simplest solution is to request a fresh reset link.
Steps:
- Go to the password reset page
- Enter email address or username
- Submit the form
- Check email for new reset link
- Click the new link within 24 hours
Reset links expire after 24 hours for security. Always use the most recent link.
Solution 2: Clear browser cache
Browser cache may store old error messages.
Steps:
- Clear browser cache and cookies
- Close all browser windows
- Open new browser window
- Request new password reset
- Click reset link from email
Keyboard shortcuts:
- Chrome/Edge:
Ctrl+Shift+Delete(Windows) orCmd+Shift+Delete(Mac) - Firefox:
Ctrl+Shift+Delete(Windows) orCmd+Shift+Delete(Mac) - Safari:
Cmd+Option+E(Mac)
Solution 3: Clear site cache
Site caching plugins may serve stale content.
Steps:
- Go to your caching plugin settings
- Clear all cache
- Request new password reset
- Test reset link
Common caching plugins:
- WP Super Cache
- W3 Total Cache
- WP Rocket
- LiteSpeed Cache
Solution 4: Check URL parameters
Verify the reset link URL is complete and unmodified.
Required URL parameters:
somresetpass=truekey=[reset_key]uid=[user_id]
Example valid URL:
https://example.com/reset-password/?somresetpass=true&key=abc123def456&uid=1
Check for issues:
- URL is not truncated
- No spaces in URL
- All parameters present
- No extra characters added
Solution 5: Increase key expiration time
Extend the 24-hour expiration period.
Add to theme's functions.php:
// Extend reset key expiration to 48 hours
add_filter( 'password_reset_expiration', 'custom_password_reset_expiration' );
function custom_password_reset_expiration() {
return DAY_IN_SECONDS * 2; // 48 hours
}
Longer expiration times reduce security. Only increase if necessary.
Solution 6: Check database connection
Verify WordPress can connect to the database.
Steps:
- Check if other WordPress features work
- Try logging in to WordPress admin
- Check database credentials in
wp-config.php - Contact hosting provider if database is down
Test database connection:
<?php
require_once( 'wp-load.php' );
global $wpdb;
if ( $wpdb->check_connection() ) {
echo 'Database connection OK';
} else {
echo 'Database connection failed';
}
Solution 7: Clear user meta
Corrupted user meta may cause key validation issues.
Using WP-CLI:
# Delete all password reset keys
wp user meta delete $(wp user list --field=ID) password_reset_key
Using phpMyAdmin:
- Access phpMyAdmin
- Select your WordPress database
- Go to
wp_usermetatable - Find rows where
meta_key=password_reset_key - Delete those rows
Only do this if you have database backup. This will invalidate all pending reset requests.
Solution 8: Check for plugin conflicts
Other plugins may interfere with key validation.
Steps:
- Deactivate all plugins except Frontend Reset Password
- Request new password reset
- Test reset link
- If it works, reactivate plugins one by one
- Identify conflicting plugin
Common conflicts:
- Security plugins with strict validation
- Custom login plugins
- User management plugins
Solution 9: Verify user exists
The user account may have been deleted.
Steps:
- Go to Users > All Users in WordPress admin
- Search for the user's email address
- Verify user account exists
- If deleted, user must re-register
Solution 10: Debug key validation
Add logging to see why validation fails.
Add to theme's functions.php:
add_action( 'validate_password_reset', 'debug_password_reset_validation', 10, 2 );
function debug_password_reset_validation( $errors, $user ) {
if ( is_wp_error( $errors ) ) {
error_log( 'Password reset validation errors: ' . print_r( $errors->get_error_messages(), true ) );
}
if ( $user ) {
error_log( 'Password reset for user: ' . $user->user_login );
}
}
Check debug log at: wp-content/debug.log
Verification
After implementing solutions:
- Request new password reset
- Check email for reset link
- Click link within 24 hours
- Verify you reach the password reset form
- Enter new password
- Confirm successful password change
Prevention
Educate users
- Use reset links within 24 hours
- Don't modify reset link URLs
- Request new link if expired
Monitor expiration
- Check if 24 hours is sufficient for your users
- Consider extending expiration if needed
- Balance security with usability
Clear cache regularly
- Configure caching to exclude reset pages
- Clear cache after plugin updates
Related issues
- Email not sending - If users don't receive reset emails
- Three-stage reset flow - Understand the reset process
- Security and validation - Learn about key validation
What's next
- Form not displaying - Fix form display issues
- Password validation issues - Fix validation problems
- Troubleshooting overview - Return to troubleshooting guide