wp-config.php Explained: The Settings That Matter and How to Edit Them Safely
What the main lines in wp-config.php do, which ones you may need to change and the mistakes that break the site.
Reference guide. This guide is written from established practice and the official documentation of the tools involved. We have not yet tested every step on a live demo site. Back up your site before you change anything.
wp-config.php sits in your site's root folder. It tells WordPress how to reach the database and several important options. Back up the file before editing.
The main parts
- Database settings:
DB_NAME,DB_USER,DB_PASSWORD,DB_HOST. Wrong values cause this error. - Authentication keys and salts: long random strings. Changing them logs everyone out, which is useful after a hack.
$table_prefix: the start of database table names. Do not change it on a live site by hand.WP_DEBUGlines: see our debug guide.WP_HOMEandWP_SITEURL: see our site URL guide.WP_MEMORY_LIMIT: see our memory guide.DISABLE_WP_CRON,DISALLOW_FILE_EDIT: see our cron guide and our security checklist.
Rules for editing
- Add custom lines above the line that says
That's all, stop editing!. - Keep quotes straight, and end every line with a semicolon.
- Save as UTF-8 without BOM. See our headers guide.
- Protect the file: permissions 600 or 640 where your host allows. See our permissions guide.
Related guides
- YouTube Video Embed Not Working or Showing an Error on Your Website
- WordPress XML Sitemap Gives 404 or Is Not Generating
- Changed the WordPress Address (URL) and Now the Site or Login Is Broken
- WordPress White Screen of Death: How to Fix a Blank Page
Did this solve it? If not, email hello@sitefixlab.org with the exact error text and we will look into it. Try the problem finder.