If you have ever opened your wp-config.php file, you have probably seen eight lines with names like AUTH_KEY and NONCE_SALT. These are WordPress security keys and salts. Many sites leave them at the placeholder value, and many people are told to “change your salts” after a hack without being told what that means.
This guide explains what the keys and salts are, when you should change them, and the safe step-by-step way to do it.
What security keys and salts are
They are eight random strings defined in wp-config.php. WordPress uses them when it secures login cookies and other protected values, which is why they should be long, random and unique to your site. The eight constants are:
AUTH_KEYandAUTH_SALTSECURE_AUTH_KEYandSECURE_AUTH_SALTLOGGED_IN_KEYandLOGGED_IN_SALTNONCE_KEYandNONCE_SALT
You do not need to remember what each one does. What matters is that all eight contain strong, unique values and that you keep them private.
When you should change them
- After a hack or suspected hack. The WordPress.org guide for hacked sites lists replacing the secret keys in
wp-config.phpas part of resetting access (FAQ: My site was hacked). See my hacked site recovery guide for the full order of steps. - When someone with access leaves. Changing the values signs out all existing sessions.
- If your
wp-config.phpmay have been exposed, for example in a public backup or a shared screenshot. - If they still contain the placeholder text from a sample file, such as “put your unique phrase here”.
There is no need to change them every week for no reason. Change them when you have a reason, and keep the rest of your security in order with the WordPress security checklist.
What happens when you change them
Because login cookies depend on these values, existing login sessions stop working once you change them. Everyone, including you, has to log in again. Your passwords, content and settings are not changed.
How to change your keys and salts, step by step
Step 1: Take a backup
Back up the site files and database before editing anything. WordPress’s backup guide explains that you need both to restore a typical site (Backups). At the very least, download a copy of wp-config.php.
Step 2: Open wp-config.php
Use SFTP or your hosting file manager. The file is normally in the WordPress root folder. WordPress also allows it to sit one directory above the install (Hardening WordPress). Open it in a plain text or code editor, not a word processor.
Step 3: Generate a new set
Use a generator you trust. WordPress.org provides one that returns eight ready-to-use lines at https://api.wordpress.org/secret-key/1.1/salt/. My WordPress salt key generator also creates a fresh set in your browser. Never take keys from a blog post, a forum or a screenshot, because published keys are no longer secret.
Step 4: Replace all eight lines
Find the eight define() lines in wp-config.php and replace the whole block with the new set. Keep this format exactly:
define( 'AUTH_KEY', 'new random value here' );
define( 'SECURE_AUTH_KEY', 'new random value here' );
define( 'LOGGED_IN_KEY', 'new random value here' );
define( 'NONCE_KEY', 'new random value here' );
define( 'AUTH_SALT', 'new random value here' );
define( 'SECURE_AUTH_SALT', 'new random value here' );
define( 'LOGGED_IN_SALT', 'new random value here' );
define( 'NONCE_SALT', 'new random value here' );
The values above are placeholders only. Use the real random values from your generator, and keep the straight quote marks and semicolons.
Step 5: Save, upload and test
Save the file, upload it if you edited a local copy, then reload your site and log in again. Confirm the front end and the dashboard both work.
Common mistakes
- Pasting keys from a word processor, which turns straight quotes into curly quotes and breaks the PHP.
- Replacing only some of the eight lines.
- Posting your
wp-config.phpor its keys publicly when asking for help. - Using the same keys on several sites.
- Changing the keys but leaving the real cause of a hack, such as an outdated plugin, unfixed.
Troubleshooting
- White screen or “critical error” after saving: there is probably a syntax error. Restore your backup copy of
wp-config.phpand try again, checking every quote and semicolon. - You are logged out: this is expected. Log in again with your normal password.
- You cannot log in afterwards: clear your browser cookies for the site and try again.
- The file is read-only: change the file permissions through your host, edit, then restore the secure permissions.
Frequently asked questions
Will changing salts delete my content?
No. Your posts, pages, users and settings stay the same. Only existing login sessions stop working.
Are keys and salts the same as passwords?
No. They are separate random values used by WordPress. You still need strong, unique passwords and two-step authentication for your users.
Is it safe to use an online salt generator?
Use the official WordPress.org generator, or a tool that generates the values in your browser and does not store them. Never use keys you found in a public post.
Next steps
Changing salts is one step in securing a site. Work through the WordPress security checklist and keep up with regular maintenance. If you would rather have it done for you, see my services or get in touch.
Written by Bilal Haider, WordPress designer and developer. Last updated: November 23, 2026.
