FAQ WordPress

What is wp-config.php and what is in it?

The one file that connects WordPress to its database and controls a handful of settings nothing else can reach.

Updated 5 min read Beginner

wp-config.php is the file that connects a WordPress installation to its database and sets a handful of core options that cannot be changed anywhere inside wp-admin. It sits at the top level of a WordPress install, alongside wp-content and wp-admin, and it is read before almost anything else WordPress does — if this file is missing or contains an error, the site cannot load at all.

What is actually in it

Database connection details

define( 'DB_NAME', 'your_database' );
define( 'DB_USER', 'your_user' );
define( 'DB_PASSWORD', 'your_password' );
define( 'DB_HOST', 'localhost' );

These four values are how WordPress finds and logs into the MySQL database holding every post, page, setting and user account. If any of them is wrong, the site shows "Error establishing a database connection" instead of loading.

The table prefix

$table_prefix = 'wp_';

WordPress prefixes every one of its database table names with this value, which allows more than one WordPress install to share a single database without their tables colliding. Changing it is sometimes recommended as a minor security precaution, though it has to be done correctly across both the database and this file together — changing one without the other breaks the site.

Authentication keys and salts

A block of several long, random-looking constants — AUTH_KEY, SECURE_AUTH_KEY, LOGGED_IN_KEY, and others alongside matching salts — used to cryptographically sign login cookies and other stored data. A fresh, unique set is generated for you when you install WordPress properly; leaving the sample placeholder values in place is a genuine weakness, since it makes login cookies theoretically easier to forge.

Debugging and error display

define( 'WP_DEBUG', false );

Controls whether WordPress logs and displays PHP errors. Turning this to true temporarily is one of the first steps in diagnosing a white screen or unexplained error — see fixing the WordPress white screen of death. It should be switched back to false once you are done, since displaying raw errors to visitors on a live site can expose information about the server that is better kept private.

Memory limit

define( 'WP_MEMORY_LIMIT', '256M' );

Sets how much memory PHP is allowed to use while running WordPress. Raising this is a common fix for "allowed memory size exhausted" errors — see increasing the WordPress memory limit for how it interacts with your hosting plan's own PHP memory setting.

Where to find it, and how to edit it safely

wp-config.php is at the top level of your WordPress install, in the same folder as wp-content. Edit it over FTP, SFTP, or your control panel's file manager rather than through anything in wp-admin, since WordPress does not provide an interface for changing it from inside the dashboard.

A syntax error here takes the whole site down

Because this file is read before WordPress does anything else, a single mistake — a missing semicolon, an unmatched quote — produces a fatal error on every single page of the site, including wp-admin. Always keep a copy of the working file before editing it, so you can restore it quickly if something goes wrong.

This file also determines the database your site uses in the first place, which is why it is central to installing WordPress manually — the entire manual installation process is really just getting this one file right, then letting the installer handle everything else.

Related reading