How to Edit wp-config.php File in WordPress?

Wp-config.php is a WordPress configuration file that contains sensitive information to control the behavior your website. WordPress software does not contain wp-config.php be default, it comes with a sample file named wp-config-sample.php. However, when you install WordPress on your site, it will generate wp-config.php file dynamically. The configuration file contains your database name, username and password. In addition, you can add many other controlling parameters.

How to Edit the File?

There are many reasons you may need to add additional parameters on your installation. One good example is to increase the PHP memory limit so that sufficient memory is allocated for running PHP scripts on your server. Unlike functions.php and other theme’s files, you can’t edit wp-config.php file from your WordPress administrator panel. You have the following two options:

  1. Use File Manager app in your hosting account
  2. Use FTP to remotely edit server files

Edit wp-config.php File with File Manager

  • Login to your hosting account.
  • Depending upon the setup you can go to cPanel or any other custom option available on your server.
  • Find File Manager app and open it.
  • Locate wp-config.php file in your root installation.
  • Click “Edit” button to modify the file.
  • Add your code and save the changes.
  • Upload the file back to the server.

Edit wp-config.php File with FTP

  • Login to your hosting using your favorite FTP client like FileZilla.
  • Navigate to your WordPress site’s root installation folder.
  • Find wp-config.php file, right click on it and choose “Edit” option.
  • Update the code in the file.
  • Save the changes to upload the file back to the server.

Root Installation

Wp-config.php is available in your WordPress site’s root installation folder.

  • If you have installed WordPress on the main domain, then you should look under “/public_html” folder.
  • If you have installed WordPress in subdomain or subdirectory, then look the file under “/public_html/folder-name/”.
RELATED:  How to Submit WordPress Sitemap in Google Search Console?


  1. Make sure to upload the file back into the server and check your site is working fine.
  2. Many hosting companies define the maximum allowed limit for the server parameters. Therefore, it is a good idea to confirm with your host before you add additional parameters in the configuration file.
  3. The order of the code in the file is important. Hence, always add your code at the bottom of the file after the comment “/* That’s all, stop editing! Happy blogging. */

Sample File Details

Below is the wp-config-sample.php file that comes with WordPress package. You can find similar details in the dynamically generated wp-config.php file also.

 * The base configuration for WordPress
 * The wp-config.php creation script uses this file during the
 * installation. You don't have to use the web site, you can
 * copy this file to "wp-config.php" and fill in the values.
 * This file contains the following configurations:
 * * MySQL settings
 * * Secret keys
 * * Database table prefix
 * @link
 * @package WordPress

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name_here' );

/** MySQL database username */
define( 'DB_USER', 'username_here' );

/** MySQL database password */
define( 'DB_PASSWORD', 'password_here' );

/** MySQL hostname */
define( 'DB_HOST', 'localhost' );

/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );

/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );

 * Authentication Unique Keys and Salts.
 * Change these to different unique phrases!
 * You can generate these using the {@link secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 * @since 2.6.0
define( 'AUTH_KEY',         'put your unique phrase here' );
define( 'SECURE_AUTH_KEY',  'put your unique phrase here' );
define( 'LOGGED_IN_KEY',    'put your unique phrase here' );
define( 'NONCE_KEY',        'put your unique phrase here' );
define( 'AUTH_SALT',        'put your unique phrase here' );
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
define( 'LOGGED_IN_SALT',   'put your unique phrase here' );
define( 'NONCE_SALT',       'put your unique phrase here' );


 * WordPress Database Table prefix.
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
$table_prefix = 'wp_';

 * For developers: WordPress debugging mode.
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 * For information on other constants that can be used for debugging,
 * visit the documentation.
 * @link
define( 'WP_DEBUG', false );

/* That's all, stop editing! Happy publishing. */

/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
	define( 'ABSPATH', __DIR__ . '/' );

/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';

You should your codes before the line that says “/* That’s all, stop editing! Happy publishing. */”.

Leave a Comment