pattern promo banner arrows
store logo

Join 1 million+ sellers & claim your .store domain now!

100% Australian Owned and OperatedSupport Centre13 24 85Pay an InvoiceLOG IN
supportcentre scaled
Support Centre
Find the answers to your questions and get the support you need with the VentraIP help centre.

Introduction to the wp-config.php file

What is wp-config.php?

As the name suggests, this is the configuration file that manages some major components of your website. This file is generated on the creation of your website during the setup and installation process.

Let’s dive into some of the important variables in this file, and what they’re used for. Knowing what information belongs in this file helps diagnose your WordPress problems.

The MySQL Settings

This section of your wp-config.php file is great for diagnosing the common “Error establishing a database connection” error and identifying conflicting data.

/** The name of the database for WordPress */ define( 'DB_NAME', 'database_name_here' );

These lines of code are used to identify your database name, which is defined inside the quotes. You can find this from the MySQL Databases section of cPanel under Current Databases.

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

These lines are for identifying the database user that WordPress logs into the above database with. You can also obtain this information from MySQL Databases in cPanel, under the MySQL Users header. If you’re diagnosing a database error, you could reset the database user’s password in cPanel and then update it in this file. As above, your values should sit inside the quotes.

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

This is to define where the database is hosted. In a vast majority of scenarios, your value will be defined as ‘localhost’, which means the database is stored on the same server as your website. In other scenarios, this is replaced with an IP address or hostname, if your database is hosted on a different server from your web hosting.

Authentication Keys and Salts

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' );

Modifying this section could be considered an advanced website admin task. When you create your website and your wp-config.php file is generated, it will also generate some security hashes called ‘salts’ which are stored in this file. Most site admins will never modify this section and retain the randomly-generated salts.

If you’re interested in increased site security, it is a great practice to replace these salts with new hashes intermittently. One useful purpose for modifying this section of your wp-config.php file is to force all logged-in users to lose their session. The website has a generator that will create new salts for you by clicking this link. You can easily copy the randomly-generated salts straight from this page and paste them into your config file to replace the current values.

Your Database Table Prefix

/** * 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_';

Here, you can change your table prefix, which does not modify the current database table structure, but instead tells WordPress what naming scheme to look for when reading your site’s database. For many sites, the default prefix is ‘wp_’. A great reason for modifying this value is when you’ve changed the prefixes in your database tables (either in phpMyAdmin or Remote MySQL) to a more secure and less predictable prefix. The more this prefix looks like a password, the more secure it is!

Debugging Mode

/** * 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 );

In this section, you can change the false value to true to enable debugging mode. This is a useful tool in WordPress for identifying problems when trying to make changes to your website, and displays error messaging whenever a process fails to run. A common situation that might call for this is if you get the dreaded ‘white screen’ after changing or updating your plugins and themes.

Changing the WordPress Address and Site Address

define('WP_HOME',''); define('WP_SITEURL','');

By default, these lines of code are not included in your wp-config.php file but can be added at any time to change the URLs that your WordPress website uses. You can insert this to the bottom of your file to overwrite your current setting for Site Address and/or WordPress Address, by swapping out in the code above.

This method is best suited for a temporary change – such as when you’re running a staging site or testing a new domain name. If you intend on changing your URL permanently, it is best to practise to do this via the WordPress Settings in the General sub-section.

If you’re having issues getting your domain name to work, it is great to check this part of your wp-config.php file as part of your diagnosis to ensure there are no conflicting values set.

Changing the Uploads Directory

define( 'UPLOADS', 'wp-content/uploads' );

Once again, the above line of code is not in your configuration file by default, but you can use this as a measure to overwrite your site’s current uploads directory. By default, your WordPress site will use a directory called wp-content/uploads. Changing this can be useful for file organisation or site staging purposes.

It is best to practise to change your uploads directory via the WordPress Settings in the Media sub-section to change this permanently.

If your site is having issues displaying content, or you cannot upload new media to your website, this part of your wp-config.php file is a great place to check for conflicts.

Other Uses of the wp-config.php File

There are plenty more variables and additional lines of code you can utilise in this configuration file – what we’ve listed here are just some of the most common uses and how they can be used to diagnose your WordPress troubles.

You can find a full list of variables on the website here.

misc content center scaled