+254725682556 +254725052660 [email protected]
Client Area

WordPress

What Is wp-config.php and How Do You Edit It Safely?

wp-config.php is the single most important file in your WordPress installation. It stores your database connection details and a set of core settings that control how WordPress behaves. You rarely need to touch it, but some fixes (like turning on debug mode or raising a memory limit) require editing it directly.

What wp-config.php controls

This file sits in the root folder of your WordPress install (usually public_html, or a subfolder if WordPress is installed there). It typically defines:

  • Your database name, username, password, and host, so WordPress can connect to its database.
  • The table prefix used for your WordPress database tables.
  • Security keys and salts used to encrypt login session data.
  • Debug settings, used to show or hide PHP errors on the site.
  • The memory limit WordPress is allowed to use.
  • Whether theme and plugin files can be edited from inside wp-admin.

Before you edit it

Always make a copy of wp-config.php before changing it. A single typo, like a missing semicolon, can take your whole site down with a white screen or a "critical error" message. Having the original file saved means you can undo the change in seconds.

How to edit wp-config.php safely

The process is the same whether your hosting account uses cPanel or DirectAdmin, since both use a browser-based File Manager:

  1. Log in to your control panel and open File Manager.
  2. Navigate to the folder where WordPress is installed (usually public_html).
  3. Find wp-config.php in the file list.
  4. Right-click it and choose Copy to make a backup copy, for example wp-config-backup.php, before changing anything.
  5. Right-click the original file and choose Edit (or Code Editor) to open it in the browser-based editor.
  6. Add your new line just above the comment that reads /* That's all, stop editing! */.
  7. Click Save Changes, then reload your website to confirm it still loads normally.

Common things people add to wp-config.php

  • define('WP_DEBUG', true); to turn on debug mode and see what's causing an error.
  • define('WP_MEMORY_LIMIT', '256M'); to raise the memory WordPress can use.
  • define('FORCE_SSL_ADMIN', true); to force the admin area to load over HTTPS.
  • define('DISALLOW_FILE_EDIT', true); to stop theme and plugin files being edited from wp-admin, as a security measure.

Only add one setting at a time, then check that your site still works before moving on to the next change.

What to do if your site breaks after an edit

If your site shows a blank screen or an error after saving, don't panic:

  1. Go back into File Manager.
  2. Delete or rename the edited wp-config.php.
  3. Rename your backup copy back to wp-config.php.
  4. Reload your site. It should be back to normal.

If you need to dig deeper into what caused the error, see our guide on enabling WordPress debug mode to find and fix the underlying issue.