The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Back up your site before editing wp-config.php. Find the file in your WordPress installation’s root directory, open it in a plain-text editor—or use WP-CLI’s wp config edit—and change only the setting required for your specific task. Check the site afterward; if the edit breaks it or locks you out, restore the known-good file.
What wp-config.php does—and when to edit it
wp-config.php is one of WordPress’s most important files. It is normally in the root of the WordPress installation and contains core configuration, including the values WordPress uses to connect to its database. Because it can affect whether the site works, most site owners do not need to edit it routinely. Make a change for a specific setup or troubleshooting need, and follow instructions for that particular setting rather than applying a generic edit.
For a manual installation, WordPress’s configuration guidance and installation guide explain how to create the file from wp-config-sample.php and enter the database settings. The key values are DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST. The host is often localhost, but that is not universal: use the value provided by your hosting provider.
Back up before making a change
Save a known-good copy of wp-config.php before you edit it. WordPress recommends regular backups before changing advanced settings. Follow your host’s instructions for backing up the rest of the site as well; a copy of this one file is not a full site backup. Keep the file somewhere you can retrieve it if the edited version prevents WordPress from loading.
#1 Best Overall
Choose an editing method
The right route depends on the access your host provides and whether you are comfortable with a command line. WordPress does not endorse a particular editor or hosting provider.
| Route | What it involves | Best fit |
|---|---|---|
| Host file manager, FTP, or SSH | Access the WordPress installation files, then open wp-config.php in a plain-text editor. |
You have file access through your host or an FTP client and know how to locate the installation root. |
| WP-CLI | Run wp config edit to open wp-config.php in the system editor. By default, WP-CLI expects the file in the WordPress installation root. |
You have WP-CLI and command-line access and are comfortable using the system editor. |
Host tools, file paths, permissions, and available access methods vary. Follow your provider’s instructions for connecting to the server and locating the site files.
Rank #2
Edit the file safely
- Locate the WordPress installation root. Find the directory containing the site’s WordPress files;
wp-config.phpis normally there. The exact server path depends on the installation and host. - Open the file as plain text. WordPress says the file can be edited in any plain-text editor and warns against using a word processor. A host file manager, FTP workflow, or SSH session can provide access to the file.
- Alternatively, open it with WP-CLI. From the WordPress installation context, run
wp config edit. The command launches the system editor for the configuration file. - Make only the change required. For a database connection issue, verify the database name, username, password, and host against the information from your host or installation records. For another task, use the specific documented constant or instruction. Do not guess values or change unrelated settings.
- Save the file and check the site. Confirm that the site loads and that the task you intended to address is resolved.
Protect credentials and diagnostic information
The database settings in wp-config.php are sensitive. Use the values assigned by your host, and do not expose real credentials in screenshots, examples, or support requests.
If troubleshooting involves debug logs, handle them carefully. WordPress’s configuration reference identifies wp-content/debug.log as the default log location, warns that publicly accessible logs can reveal information, and recommends removing the file after use. Where possible, keep logs above the public site root or restrict access. Do not leave diagnostic output exposed on a live public site.
Rank #3
Understand the effect of a setting before changing it
Some configuration constants override values stored elsewhere. For example, WP_SITEURL in wp-config.php overrides the stored siteurl setting. Removing the constant can allow WordPress to use the previous database value again. Before adding, changing, or removing a constant, understand what it overrides and how that will affect your particular site.
Recover if the edit breaks the site
A syntax error or incorrect value can cause errors, a blank screen, a crash, or loss of dashboard access. If that happens, use your file-access method to replace the edited file with the known-good backup. WordPress’s troubleshooting guidance describes recovery by removing the changed file and restoring a good copy. Once the site is working, review the edit and correct only the intended setting before trying again.
Quick Recap
Best Value
Rank #4
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

