Explainers · Explainer
What Is wp-config.php? A Plain Explanation

Short answer
wp-config.php is the file that stores your WordPress site's base settings, including the database login, security keys, and core options. It sits in the root folder of your install, and WordPress reads it on every page view that is not served from a cache file. You edit it to change settings such as debug mode, memory limits, and the site address, but always back it up first because a typo can stop the site from loading.
Key takeaways
- wp-config.php holds the database login, eight security keys and salts, the table prefix, and optional settings.
- The file sits in the root folder of your WordPress install, next to wp-admin, wp-includes, and wp-content.
- The WordPress setup process creates wp-config.php, and it is not included in the download.
- WP_DEBUG defaults to false, and the default debug log file is wp-content/debug.log.
- WordPress tries to raise PHP memory to 40MB for a single site and 64MB for multisite.
- Always back the file up before editing, and add new lines above the “That's all, stop editing!” comment.
What is wp-config.php?
wp-config.php is the file that stores your WordPress site's base settings, including the database login, security keys, and core options.
WordPress.org's developer handbook calls it one of the most important files in your WordPress installation, and says it holds your base configuration details, such as database connection information.
Editing wp-config.php WordPress reads the file on every page view that is not served from a cache file, so a typo here can stop the whole site from loading.
The file is plain PHP. Most of it is a list of define() lines, each setting one named value, plus one variable for the database table prefix. You do not need to learn PHP to read it, but you do need to respect its syntax: every line needs its quotes, comma, and closing semicolon.
Where is wp-config.php located?
wp-config.php sits in the root folder of your WordPress install, next to the wp-admin, wp-includes, and wp-content folders.
When you first download WordPress, the file is not included. The WordPress setup process creates it for you from the details you enter during installation, according to the developer handbook. On a managed host, the installer usually creates it without you ever seeing it.
You open it through your host's file manager or an SFTP client. In a file manager, you go to the folder that holds your site, right-click the file, and choose Edit. If you use SFTP, download the file, edit it on your computer, and upload it again.
What is inside wp-config.php?
wp-config.php holds four groups of settings: database login details, security keys and salts, the table prefix, and optional constants that switch features on or off.
The database block comes first, with four constants for the database name, user, password, and host. Next comes the block of eight security keys and salts. Then the table prefix variable.
The rest of the file is optional constants you add only when you need them, such as debug mode or a memory limit.
The file ends with a comment line that reads “That's all, stop editing! Happy publishing.” By convention, new settings go above that line, never below it.
What are the database settings in wp-config.php?
The database settings are four constants, DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST, that tell WordPress which database to open and how to log in.
Your host gives you these four values when it creates the database, and they must match exactly. If any one of them is wrong, WordPress cannot open the database and shows the “Error establishing a database connection” message. How to fix that database error
DB_HOST is the address of the database server. Your host panel shows the exact value to use, so copy it from there instead of guessing. Some hosts run the database on the same server as the site, while others use a separate address.
What are the security keys and salts in wp-config.php?
The file holds eight long random strings, four keys and four salts, that WordPress mixes into the hashes that protect login cookies.
The eight values are AUTH_KEY, SECURE_AUTH_KEY, LOGGED_IN_KEY, NONCE_KEY, AUTH_SALT, SECURE_AUTH_SALT, LOGGED_IN_SALT, and NONCE_SALT. They are long random strings, and each install should have its own set. Never copy the keys from another site or from a tutorial.
WordPress.org runs a free generator at api.wordpress.org/secret-key/1.1/salt/ that returns a fresh set of eight ready-to-paste define() lines. Visit the page, copy the block, and paste it over the old lines. Changing the salts ends every active login session, because the old cookies no longer match, so everyone must log in again.
What is the table prefix in wp-config.php?
The table prefix is the short label WordPress puts at the start of every database table name, and the default is wp_.
The prefix is set in the $table_prefix variable, not in a define() line. The developer handbook says you can change it if you want something other than wp_ for your database prefix, and that only numbers, letters, and underscores are allowed.
The handbook also notes that you can run more than one WordPress install in a single database if each one has its own prefix. That is how installs that share a database keep their tables apart.
Changing the prefix on a live site is a bigger job than editing one line, because every table name must change too, so set it at install time if you want a custom one.
Which settings do people change most often in wp-config.php?
The settings people change most are WP_DEBUG for error logging, WP_MEMORY_LIMIT for memory errors, WP_POST_REVISIONS for revision limits, and WP_SITEURL and WP_HOME for the site address.
| Constant | What it controls | Typical value |
|---|---|---|
| WP_DEBUG | Shows PHP errors and warnings | true to turn on, false to turn off |
| WP_DEBUG_LOG | Writes errors to wp-content/debug.log | true, used with WP_DEBUG |
| WP_MEMORY_LIMIT | PHP memory WordPress may use | 96M or 128M |
| WP_POST_REVISIONS | How many revisions WordPress keeps | false to turn off, 3 to keep three |
| AUTOSAVE_INTERVAL | Seconds between post autosaves | 180 |
| EMPTY_TRASH_DAYS | Days before trash is emptied | 30 |
| WP_SITEURL and WP_HOME | WordPress address and site address | Full https URL, no trailing slash |
| DISALLOW_FILE_EDIT | Blocks the theme and plugin file editor | true |
| WP_AUTO_UPDATE_CORE | Which core updates run by themselves | minor, true, or false |
WP_DEBUG defaults to false, according to the developer handbook. Setting it to true also raises the error reporting level to E_ALL and turns on warnings for deprecated functions. The default debug log file is /wp-content/debug.log.
WordPress tries to raise PHP memory to 40MB for a single site and 64MB for multisite, so set WP_MEMORY_LIMIT higher than that if you see an “Allowed memory size exhausted” message. Some hosts do not allow the limit to rise from wp-config.php, and then you must ask the host to raise it.
WP_POST_REVISIONS defaults to true, which means revisions stay on. Set it to false to stop saving them, or to a number such as 3 to keep only three per post. Autosaves run every 60 seconds by default, and setting AUTOSAVE_INTERVAL to 180 stretches the gap to three minutes.
Trash empties after 30 days by default, and setting EMPTY_TRASH_DAYS to 0 turns the trash off. WP_ENVIRONMENT_TYPE accepts local, development, staging, and production, and when it returns development, WordPress sets WP_DEBUG to true if you have not defined it.
WP_AUTO_UPDATE_CORE takes three values: false turns all core updates off, true turns on minor and major updates, and 'minor' keeps the default of minor releases only.
DISALLOW_FILE_EDIT set to true blocks the theme and plugin file editor in the admin area, which stops an admin account from editing code files by accident.
How do you edit wp-config.php safely?
Back up the file first, edit it in a plain-text editor, add new lines above the “That's all, stop editing!” comment, and reload your site right after saving.
- Download a copy of the file to your computer before you change anything. If an edit breaks the site, uploading that copy puts the old settings back.
- Open the file in a plain-text or code editor. The developer handbook warns to check the single quotes around every value and to leave nothing after the closing PHP tag.
- Add new lines above the “That's all, stop editing!” comment. Check every line for its quotes, comma, and closing semicolon before you save.
- Save, upload the file if you edited it locally, then reload your site in a new tab. If the site loads, the edit worked.
- If you use WP-CLI, you can set a value without opening the file. The command
wp config set WP_DEBUG true --rawupdates the constant in place, as shown in the WP-CLI command reference.
What happens if wp-config.php has an error?
A syntax error in wp-config.php stops WordPress from loading, so the site shows a blank page or a PHP error instead of your content.
The most common cause is a missing quote, comma, or semicolon on an edited line. Restore your backup copy first, then compare it with the edited file to find the broken line. How to fix a wp-config.php write error
Since WordPress 5.2, recovery mode shows the message “The site is experiencing technical difficulties” instead of a white screen when a plugin causes a fatal error, according to the developer handbook.
That recovery mode does not fix a broken wp-config.php, because the file loads before the rest of WordPress, so a backup copy is still your fastest way back.
Should you ever delete wp-config.php?
No, never delete wp-config.php, because WordPress needs it to connect to the database and load your site.
Without the file, WordPress has no database login and no settings, so it cannot show your content. If the file goes missing, WordPress starts the setup process again, because that process is what creates the file in the first place.
Keep a backup copy of the file somewhere safe. If you have never made a site backup, read how cPanel backups compare with plugin backups first. The file holds your database password in plain text, so store that backup where only you can reach it.
What mistakes should you avoid with wp-config.php?
The mistakes to avoid are editing without a backup, pasting settings below the “That's all” comment, leaving debug mode on, and sharing the file.
- Editing without a backup. Download a copy first, every time.
- Pasting new lines below the “That's all, stop editing!” comment. Add them above it.
- Leaving WP_DEBUG on in production. The developer handbook says error messages should be logged, not shown to visitors, and the debug log should not sit in a public folder where anyone can open it. Turn debug off when you finish, and delete the log file.
- Leaving WP_ALLOW_REPAIR on. The handbook says to enable it only when you need it and turn it off once the issue is solved, because anyone can open the repair page without logging in. The repair script lives at
wp-admin/maint/repair.php. - Sharing the file or posting it in a support forum. It holds your database password, so share only the lines you need, with passwords removed.
- Changing values you do not understand. If a guide tells you to add a constant, check what it does in the developer handbook first.
Frequently asked questions
Where is wp-config.php located?
It sits in the root folder of your WordPress install, next to the wp-admin, wp-includes, and wp-content folders. You reach it through your host file manager or an SFTP client. When you first download WordPress, the file is not included, and the setup process creates it from the details you enter.
Do I need to edit wp-config.php as a beginner?
Most beginners never need to touch it. You only edit it when a guide or your host asks you to change a setting, such as turning on debug mode, raising the memory limit, or fixing the site address. For everyday tasks like writing posts and changing themes, the admin area is enough.
What happens if I make a mistake in wp-config.php?
A syntax error stops WordPress from loading, so your site shows a blank page or a PHP error. The fix is to restore the backup copy you saved before editing, then compare the two files to find the broken line. A missing quote, comma, or semicolon is the usual cause.
Can I change my database password in wp-config.php?
You can change the DB_PASSWORD value in the file, but that alone is not enough. You must first change the password for the database user in your host panel, then put the same new password in wp-config.php. If the two do not match, WordPress cannot connect and shows a database connection error.
Is it safe to share my wp-config.php file?
No. The file holds your database password in plain text, so anyone with it can open your database. Never post the whole file in a forum or send it to someone you do not trust. If you need help, share only the lines that matter, with the password removed.
Sources
- Editing wp-config.php Developer.WordPress.org
- Debugging in WordPress Developer.WordPress.org
- wp config set - WP-CLI Command Developer.WordPress.org
- WordPress Secret Key Generator WordPress.org
- Errors and Logging Configuration Options PHP.net
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.


