Skip to content

Home  /  Blog  /  WordPress basics

What Is wp-config.php and Why You Should Never Share It

wp-config.php is the WordPress configuration file that holds your database login details, security keys and important settings. Because it contains the keys to your database, it should be protected, edited carefully and never shared in emails, support forums or screenshots.

4 min readWordPress basicsWritten by WP Mate, Warrnambool VIC
WP Mate koala mascot beside a laptop, representing Australian WordPress support
01

What the file does

When WordPress starts, it reads wp-config.php to learn how to connect to its database and how to behave. It sits in the root folder of your website and is one of the few files that is not part of WordPress core, because it is unique to your site. If it is missing or wrong, WordPress cannot start properly, and you may see the database connection error.

02

What it typically contains

ItemPurpose
Database name, user, password, hostLets WordPress reach the database
Authentication keys and saltsSecure login cookies and sessions
Table prefixPrefix on your database tables
Debug settingsControls error display and logging
Memory and other constantsAdjust limits and behaviour

Not sure what is going on with your website?

Tell us what you are seeing and we will outline the next step before any chargeable work.

03

Why it is sensitive

Anyone who reads the database password and host can potentially access your data if the database is reachable. Posting the file in a forum when asking for help, or emailing it to a stranger, exposes those keys. If you must share a snippet, remove the passwords and keys first, and rotate credentials afterwards if you think they were exposed.

04

Common problems linked to the file

  • Wrong database details after a migration or host change
  • Debug mode left on, revealing errors to visitors
  • A syntax mistake after a manual edit, causing a white screen
  • Memory limit settings that do not match the host
  • Unauthorised edits as part of a compromise
05

Editing it safely

Always take a backup first, use a plain text editor and make one change at a time. A single missing quote or bracket can stop the site. After the change, test the site and, if something breaks, restore the previous version. Do not leave debug mode switched on for a live website.

06

Protecting the file

  • Use sensible file permissions so it is not writable by everyone
  • Keep it out of public backups or shared folders
  • Use strong, unique database passwords
  • Limit who has hosting file access
  • Monitor for unexpected changes
07

Debug settings and why they matter

WordPress includes debug settings that control whether errors are displayed or logged. They are very useful while diagnosing a fault, but leaving error display on for a live website can reveal file paths and other details to visitors and attackers. The safe approach is to enable logging to a file, not to the screen, only while investigating, and to turn it off afterwards. If you ever see raw error messages on your public pages, that is a sign debug display has been left on and should be switched off promptly.

08

Salts, keys and rotating them

The authentication keys and salts in the configuration file are used to protect login cookies. Changing them logs everyone out, which is useful after a suspected compromise because it invalidates stolen sessions. A recovery plan after a security incident often includes generating new keys, changing database and hosting passwords and reviewing user accounts. It is a quick step with a meaningful security benefit, and it is one reason the file deserves care and a current backup.

09

When to get help

If you suspect the file was altered or your credentials were exposed, treat it as a security issue and read what to do when WordPress is hacked. For configuration faults, see WordPress repair or contact us.

Want this looked after for you?

WP Mate maintenance plans cover managed updates, daily offsite backups, security scanning and 24/7 uptime monitoring.

Think your website is hacked? Get a safe recovery plan.

How we can help

Services related to this guide

Hacked website help

Assess the damage and plan a safe recovery.Get Security Help →

WordPress repair

Broken website? We investigate the cause and fix it safely.Get a Repair Quote →

Talk to WP Mate

Not sure which service fits? Ask us and we will point you the right way.Contact us →

Frequently asked questions

Usually in the root folder of your WordPress installation, or one level above it.

It can be moved one level above the root in many setups, but changes should be made carefully with a backup.

Not unless you remove every password, key and salt first.

Ready to get your website sorted?

Based in Warrnambool, Victoria, helping Australian businesses online. Tell us what is happening.

Get WordPress help

Tell your mate what's going wrong.

Send us a few details and we’ll work out the next step. Please don’t include passwords or payment details.

  • Australian support in plain English
  • Clear scope and next steps before chargeable work
  • Backup and recovery plan before live changes

Please don't include passwords, payment card numbers or private customer data. If we need access, we'll arrange a secure way to share it.