The wp-config.php
file is a core configuration file for WordPress. It contains essential settings that allow your website to connect to its database and function properly.
This file is created when you first set up WordPress, and it stores information such as:
- Database credentials (database name, username, password, and server)
- Security keys that add an extra layer of protection to your site
- Debugging settings that help you troubleshoot issues
You’ll find the wp-config.php
file in the root directory of your WordPress installation. If you’re using a managed WordPress host, you may not need to interact with this file often. But knowing where it is and what it does can be helpful if you need to customize or troubleshoot your site.
Note: This document is meant to serve as a helpful guide for advanced troubleshooting; however, the procedures described are beyond the scope of our support policy and we cannot provide direct assistance with implementing them.
If you would like to seek assistance from a qualified WordPress/WooCommerce Developer, we highly recommend Codeable, or a Certified WooExpert.
Where do you find wp-config.php?
↑ Back to topYou can find the wp-config.php
file in the root directory of your WordPress installation. This is the main folder where WordPress is installed, and it often includes other folders like wp-content
, wp-includes
, and wp-admin
.
To access wp-config.php
:
- Log in to your hosting account: Use the control panel or file manager provided by your web host. Most managed WordPress hosts offer a file manager in their dashboard.
- Navigate to the root directory: Look for a folder named something like
public_html
, www, or a similar directory where your WordPress site files are stored. - Locate wp-config.php: Once you’re in the root directory, find the
wp-config.php
file. Be careful when opening it, as any changes to this file can impact your site’s functionality. - Download or open to edit: You can download a copy for safe editing on your computer, or open it directly in the file manager if your host allows this. Always create a backup before making any changes.
If you are unsure how to access your site’s file manager or root directory, reach out to your hosting provider for help.
What’s in the wp-config file?
↑ Back to topThe wp-config.php
file includes key settings for your WordPress site, such as:
- Database Connection Details: These settings include the database name, username, password, and host. They enable WordPress to connect to the database where all your site’s content, settings, and user information are stored. If any of these details change or are incorrect, WordPress won’t be able to access the database, and your site won’t load.
- Security Keys and Salts: WordPress uses security keys and salts to protect user login sessions and cookies. These are random strings of characters that make it much harder for hackers to crack passwords or access your site without permission. WordPress generates these for you, but you can update them manually for added security.
- Database Table Prefix: WordPress stores data in tables within your database. The table prefix is a short code, like
wp_
, that appears at the beginning of each table’s name. Changing this prefix can add a layer of security by making it harder for attackers to guess table names, which is especially helpful on sites with default setups. - Debugging Mode: Enabling debugging mode in WordPress displays errors and warnings on your site, which can help you troubleshoot and identify issues. It’s useful during development or when trying to fix an error. But should be disabled on live sites to prevent visitors from seeing technical information.
- File Permissions: The
wp-config.php
file can include file permissions settings that control who can read, write, or execute certain files within your WordPress installation. Proper permissions help protect sensitive files and prevent unauthorized access to critical parts of your site. - Memory Limits: WordPress uses memory to handle tasks on your site, such as loading plugins, processing large images, or handling multiple visitors at once. By setting memory limits in the
wp-config.php
file, you can allocate more resources to WordPress, which can improve site performance, especially if you run resource-intensive plugins or themes.
These settings allow WordPress to function correctly, protect your site, and provide a stable experience for visitors.
Editing wp-config
↑ Back to topIf you plan to edit the wp-config.php
file, make sure to back up your site first. This file is essential for WordPress to function properly, and any mistakes can make your site inaccessible. Create a backup of both your files and database to ensure you can easily restore your site if something goes wrong.
Many managed WordPress hosts offer quick backup options, or you can use a plugin to create a full backup. Taking this step will give you a safety net and prevent potential downtime for your site.
There is in-depth information on how to edit the file itself at WordPress.org’s guide to editing wp-config.
Enable debug mode through wp-config.php
↑ Back to topDebug mode in WordPress is a feature that displays errors, warnings, and notices on your site. It’s useful for troubleshooting issues because it reveals specific details about any problems with themes, plugins, or custom code.
By enabling debug mode, you can identify what needs fixing, making it easier to resolve errors and improve site performance.
To enable debug mode on your WordPress site through the wp-config.php file:
- Access the wp-config.php file: Use your host’s file manager or an FTP client to locate the wp-config.php file in the root directory of your WordPress installation.
- Open the file for editing: Download a copy of the file to your computer or open it directly in the file manager if your host allows this.
- Find the debug line: Look for the following line in the file:
define('WP_DEBUG', false);
If you don’t see this line, you can add it just above the line that says /* That's all, stop editing! Happy blogging. */
.
4. Enable debug mode: Change false to true so it reads:
define('WP_DEBUG', true);
5. Save your changes: Save and close the file, then refresh your site. WordPress will now display errors and warnings, which can help you troubleshoot issues.
Remember to set WP_DEBUG
back to false after troubleshooting to prevent visitors from seeing error messages.
Keep debug mode enabled without displaying error messages
↑ Back to topYou can also enable debug mode but prevent any error messages from loading on the front end, and storing them to a log file instead, by following these steps:
- Access the wp-config.php file: Use your host’s file manager or an FTP client to locate the wp-config.php file in the root directory of your WordPress installation.
- Open the file for editing: Download a copy of the file to your computer, or open it directly in the file manager if your host allows this.
- Add the debug settings:
- Look for or add the following lines in the file, just above the line that says
/* That's all, stop editing! Happy blogging. */
.
- Look for or add the following lines in the file, just above the line that says
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);
4. Save your changes: Save and close the file, then refresh your site. Errors will now be recorded in the debug log file without displaying publicly.
Remember to set WP_DEBUG
and WP_DEBUG_LOG
back to false once you finish troubleshooting.For more information, check out the WordPress Debugging Guide on the official WordPress Developer site.
Questions and Support
↑ Back to topDo you still have questions and need assistance?
- Get in touch with a Happiness Engineer via our Help Desk. We provide support for extensions developed by and/or sold on WooCommerce.com, and Jetpack/WordPress.com customers.
- If you are not a customer, we recommend finding help on the WooCommerce Support Forum or hiring a WooExpert agency. They are trusted agencies with a proven track record of building highly customized, scalable online stores. Learn more about WooExpert agencies.