Security · Guide
How to Change WordPress Security Keys and Salts

Short answer
To change WordPress security keys and salts, generate a fresh set from the official secret-key generator or run wp config shuffle-salts, then replace the eight lines in wp-config.php. Every user is signed out at once and must log in again.
Key takeaways
- There are eight values: four keys, which are required, and four salts, which are recommended.
- Changing the keys invalidates all existing cookies and signs every user out at once.
- Generate fresh values from the official secret-key generator or with wp config shuffle-salts.
- Never edit wp-config.php in a word processor, and back it up before every change.
- Rotate keys after a break-in, when an admin leaves, or when the values may have leaked.
What are WordPress security keys and salts?
Security keys and salts are eight long random strings in wp-config.php that sign login cookies so they cannot be forged.
Four of them are keys and four are salts: AUTH_KEY, SECURE_AUTH_KEY, LOGGED_IN_KEY, NONCE_KEY, AUTH_SALT, SECURE_AUTH_SALT, LOGGED_IN_SALT, and NONCE_SALT. The wp-config.php handbook says the four keys are required for enhanced security, while the four salts are recommended.
A key adds random elements to a password so it is harder to guess, and a salt further strengthens the result. Together they protect the cookies WordPress stores in your browser after you log in.
Each install should have its own set. Keys copied from a tutorial, shared between sites, or left at the sample values from wp-config-sample.php give an attacker a known starting point.
| Constant | Type | What it signs |
|---|---|---|
| AUTH_KEY | Key | Login cookies |
| SECURE_AUTH_KEY | Key | Admin cookies over HTTPS |
| LOGGED_IN_KEY | Key | Logged-in cookies |
| NONCE_KEY | Key | Nonces for forms and links |
| AUTH_SALT | Salt | Login cookie signing |
| SECURE_AUTH_SALT | Salt | Admin cookie signing |
| LOGGED_IN_SALT | Salt | Logged-in cookie signing |
| NONCE_SALT | Salt | Nonce signing |
The four keys are required and the four salts are recommended, according to the wp-config.php handbook. WordPress will create salts on its own if none are set, but a full set of eight is the standard install.
When should you change your security keys and salts?
Change them after any suspected break-in, when someone with admin access leaves, and whenever the current values may have been shared or leaked.
The most urgent case is a hacked site. If an attacker holds a valid login cookie, changing your password alone does not end their session, but new keys do, since the old cookies stop working.
Other good times to rotate them:
- After a developer or admin leaves the project.
- After wp-config.php was shared, emailed, or stored in a public place.
- After a backup or staging copy leaked outside your control.
- After moving a site that was built from a copied install.
There is no fixed schedule in the official docs, so tie rotation to events like the ones above rather than a date on the calendar. A routine change every few months is fine, but an event-driven change is the one that matters.
How do you change keys and salts with the WordPress generator?
Open the official secret-key generator, copy the eight lines it returns, and paste them over the old block in wp-config.php.
The handbook recommends the online generator and says you can change the keys at any point to invalidate all existing cookies. The generator lives at the WordPress secret-key service, and each visit returns a fresh set.
Follow these steps:
- Back up wp-config.php first, so a bad edit is a quick restore.
- Open the generator in your browser and copy all eight
definelines. - Open wp-config.php in a plain text editor or your host file manager.
- Find the old block of eight key and salt lines and replace it with the new block.
- Save the file and log in again at wp-admin.
Never use a word processor to edit the file. The handbook warns against it, since Word adds hidden formatting that breaks PHP code.
Check that the site still loads right after saving. A missing quote or semicolon in wp-config.php breaks the whole site, so keep the backup close until you have logged in again.
How do you change keys and salts with WP-CLI?
Run wp config shuffle-salts from the site root, and WP-CLI fetches fresh values and writes them into wp-config.php for you.
WP-CLI is the official command-line tool for WordPress, and its shuffle-salts command page shows the command and its result. The command needs no arguments for the standard eight keys.
wp config shuffle-salts
The command prints “Success: Shuffled the salt keys.” when it finishes. That is the whole job, and it avoids the copy-and-paste errors that come with editing the file by hand.
You can shuffle one key at a time if needed. The command accepts key names as arguments, so wp config shuffle-salts NONCE_KEY replaces only that value. Use the --force flag only when adding a key WordPress does not know, such as WP_CACHE_KEY_SALT.
This method suits sites you manage over SSH or through a deployment script. If you do not have command-line access, use the generator method above instead.
How do you change keys and salts with a plugin?
Install a plugin built for salt rotation, open its settings, and use its change-now button to replace all eight values at once.
A rotation plugin suits site owners who do not want to edit files or use the command line. Salt Shaker is one plugin built for this job, and it can also rotate keys on a schedule, according to the Kinsta guide to changing WordPress security keys.
The same guide notes that general security plugins can do the job too. Sucuri Security includes a button to generate new security keys, so a site already running it does not need another plugin.
Follow these steps with any rotation plugin:
- Install the plugin from the WordPress.org directory or the vendor site.
- Open its settings page and read what it will change.
- Run the change once, then log in again to confirm the site works.
- Set a schedule only if the plugin offers one and you want it.
Keep the plugin count low. If you already run a security plugin that rotates keys, use that one instead of adding a second plugin for the same job.
What happens after you change the keys and salts?
Every logged-in user is signed out at once, including you, and everyone must log in again with their password.
This is the intended effect, not a side effect. The handbook states that changing the keys invalidates all existing cookies, which means any session built on the old values stops working right away.
Tell your team before you rotate keys on a live site. Editors with unsaved work in the dashboard will lose their session when they save, so ask them to save and log out first.
The change does not alter passwords, user accounts, or content. It only ends sessions. Anyone who knows their password can log straight back in, while anyone holding a stolen cookie cannot.
If the site uses a cache plugin or a content delivery network, clear the cache after the change. Cached login pages can confuse the first login after rotation, and a fresh cache avoids that.
How do you check that the new keys work?
Log out, log back in, and confirm the site loads and the admin area works, then check that other users can log in too.
Run these four checks after any rotation:
- Open the site front page and confirm it loads without errors.
- Log in to wp-admin with your own account.
- Open a post for editing and save a small change to confirm sessions hold.
- Ask one other user to log in and confirm their access works.
If the site shows a white screen or an error after the edit, restore the backed-up wp-config.php and try again. The cause is almost always a missing quote, a broken line, or text pasted below the “That's all, stop editing!” line.
If logins fail but the site loads, open wp-config.php and confirm the eight lines are complete and each value sits inside single quotes. The guide to recovering a hacked WordPress admin account covers the next steps if an admin still cannot get in.
What mistakes should you avoid?
The common mistakes are reusing keys between sites, editing the file in a word processor, and rotating keys without a backup.
Avoid these five mistakes:
- Copying the same eight values from one site to another.
- Pasting example keys from a tutorial or from the handbook page.
- Editing wp-config.php in Word or another word processor.
- Placing new lines below the “That's all, stop editing!” comment.
- Rotating keys during a launch or a sale without telling the team.
The example values in the handbook are marked “don't use these” for a reason: they are public, so anyone can read them. Your keys must come from the generator, from WP-CLI, or from a plugin that creates random values.
Keep a copy of the current wp-config.php before every change. A bad edit takes seconds to make and seconds to undo, but only if the backup exists.
How do keys and salts fit into a wider security routine?
Treat key rotation as one step beside updates, two-factor checks, and backups, not as a fix on its own.
Fresh keys end stolen sessions, but they do not close the hole the attacker used. After a break-in, update everything, review the user list, and scan the files before you call the job done.
WordPress 7.1.4 was released on 28 October 2026 as a security release, and WordPress.org says sites should update immediately, on its version 7.1.4 page. The same page states that only the most recent version of WordPress is actively supported.
The guide to running a WordPress security audit gives a monthly routine that covers updates, users, files, and backups in one pass. Pair it with the guide to backing up a WordPress site so a bad day ends in a restore, not a rebuild.
A site with fresh keys, current software, and tested backups is a site that recovers fast. Rotation is the step that cuts off the attacker, and the routine is what keeps them out.
Frequently asked questions
How often should I change WordPress security keys and salts?
Change them after a suspected break-in, when someone with admin access leaves, or when the values may have been shared or leaked. There is no fixed schedule in the official docs, so tie rotation to events rather than a date.
Does changing the keys fix a hacked site on its own?
No. Changing the keys ends every session, including sessions held by an attacker, but it does not close the hole they used. Update everything, review the user list, and scan the files as well.
What happens if my wp-config.php has no salts set?
Yes. The handbook says WordPress will generate salts on its own if none are set, because the four salts are recommended rather than required. The four keys are required, so a full set of eight is still the standard install.
My site broke after I edited wp-config.php. What do I do?
Restore the backed-up wp-config.php and try again. A white screen after editing almost always means a missing quote, a broken line, or text pasted below the 'That's all, stop editing!' line.
Does changing the keys change user passwords?
No. Passwords, accounts, and content stay the same. Only sessions end, so anyone who knows their password can log straight back in, while anyone holding a stolen cookie cannot.
Sources
- wp-config.php WordPress Developer Resources
- wp config shuffle-salts WordPress Developer Resources
- Secret-Key Generator WordPress.org
- How To Change Your WordPress Security Keys Kinsta
- Version 7.1.4 WordPress.org
- Hardening WordPress WordPress Developer Resources
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.
Related guides
About the editors
Researched from the primary sources listed above and checked against our editorial rules before publishing.


