If you are troubleshooting a WordPress site, changing database settings, or preparing a migration, you may need to find the WordPress configuration file. The file is called wp-config.php, and it contains important settings that help WordPress connect to its database and run correctly. Its exact location depends on how the site was installed, but there are a few reliable ways to find it.
In most cases, wp-config.php is in the main directory of your WordPress installation. This guide explains where to look, how to locate the file using common hosting tools, what to do if it is not in the expected place, and how to protect it once you find it.
The Standard Location of wp-config.php
For a typical WordPress installation, the configuration file is in the same directory as the main WordPress folders and files. Look for a folder containing wp-admin, wp-content, and wp-includes. The wp-config.php file is usually alongside them.
A standard installation may look like this:
public_html/
├── wp-admin/
├── wp-content/
├── wp-includes/
├── wp-config.php
├── wp-load.php
└── wp-login.php
On many shared hosting accounts, public_html is the website’s document root. It is the folder from which the server serves the site’s files. However, the document root can have a different name, such as htdocs, www, or a domain-specific folder. The key clue is the presence of the WordPress core directories, not the name of the folder.
Why WordPress Needs wp-config.php
The wp-config.php file provides WordPress with essential setup information. Most notably, it contains the database name, database username, database password, and database host. WordPress uses those details to access the database that stores posts, pages, user accounts, settings, and other site data.
The file can also define security keys, database table prefixes, debugging options, and other configuration constants. Some sites use it to set a custom content directory or control how updates and file editing work. Because it contains sensitive information, wp-config.php should be treated as a private server file rather than a public document.
Find the File in Your Hosting Control Panel
If your hosting provider offers cPanel, Plesk, or a similar control panel, its file manager is often the easiest way to locate the WordPress configuration file. First, sign in to your hosting account and open the file manager. Then navigate to the folder for the website you want to inspect.
For a site installed on the primary domain, start by opening public_html or the folder identified as the domain’s document root. For an add-on domain or a separate website, the files may be in a subfolder named after the domain. Check for wp-admin, wp-content, and wp-includes. If those folders are present, look for wp-config.php in that directory.
Some file managers display files in alphabetical order, so the configuration file may appear farther down the list than expected. You can also use the file manager’s search feature to search for the exact filename, wp-config.php. Make sure the search is limited to the correct website directory if your hosting account contains multiple sites.
Locate wp-config.php with FTP or SFTP
You can also use an FTP or SFTP client to browse your website files. Connect with the server details provided by your host, then open the website’s document root. Navigate through the folders until you find the WordPress core directories. In a standard setup, wp-config.php is in the same folder.
SFTP is generally preferable when available because it encrypts the connection. After connecting, avoid downloading or editing files for a different domain by mistake. If the account contains several WordPress installations, compare each installation’s folders and domain path before making changes.
Find the Configuration File with SSH
If your hosting plan provides SSH access, you can use the command line to check likely directories. First, change to the website’s document root. For example, if your site files are in public_html, a command might look like this:
cd ~/public_html
ls -la
The ls -la command lists files, including files that may not appear in a basic directory listing. If you are unsure which folder contains the installation, you can search for the filename from an appropriate starting directory:
find ~/ -name wp-config.php -type f 2>/dev/null
The search may return more than one result if the account hosts multiple WordPress sites, staging copies, or backups. Use the full path to identify which file belongs to the site you need. Do not edit a backup or staging configuration file unless that is the specific site you intend to work on.
Can wp-config.php Be Outside the WordPress Folder?
Yes. Although the usual location is the WordPress installation directory, WordPress can also load wp-config.php from the directory immediately above the installation directory. This is sometimes done to keep the configuration file outside the publicly served document root.
For example, a site might have the following structure:
account/
├── wp-config.php
└── public_html/
├── wp-admin/
├── wp-content/
└── wp-includes/
If you see the WordPress folders but do not see wp-config.php, check the parent directory. Do not assume that the file is missing until you have checked both locations. WordPress installations can also use custom layouts or hosting-specific tools, so the directory structure may not match a basic example exactly.
Where Is wp-config.php in a Subdirectory Installation?
A WordPress site’s web address does not always reveal where its configuration file is stored. For instance, a site may appear at example.com/blog while its WordPress core files are installed in a folder named blog. In that case, the configuration file is generally in the directory containing that installation’s wp-admin, wp-content, and wp-includes folders, or in the parent directory if the installation is configured that way.
Some sites have WordPress core files in the document root while displaying the site at a different URL path. Others use a custom directory structure created by a developer or a hosting platform. Follow the location of the actual WordPress core files rather than relying only on the visible URL.
What If You Cannot Find wp-config.php?
If the file is not where you expect, use a careful checklist before changing anything:
- Confirm that you are looking in the correct domain’s document root.
- Check the directory containing
wp-admin,wp-content, andwp-includes. - Look one directory above the WordPress installation.
- Search the account for the exact filename, especially if it contains multiple sites.
- Check whether your host uses a managed WordPress dashboard or a custom file layout.
- Ask your hosting provider or site administrator to confirm the installation path.
Do not create a new wp-config.php simply because you cannot find the existing one. A working site may be using a configuration file in another directory, or a managed hosting setup may handle configuration differently. Creating or replacing the file without the correct database details can make the site inaccessible.
You may see a file named wp-config-sample.php in a WordPress installation. This is a sample template, not the active configuration file. It does not automatically contain the correct database credentials or settings for your website.
How to Open or Edit wp-config.php Safely
If you need to inspect or update the file, make a backup before editing it. Download a copy or create a duplicate in a secure location. Then use a plain-text or code editor rather than a word processor, which can introduce formatting that breaks PHP files.
Be especially careful when changing database credentials, security keys, or PHP constants. A missing semicolon, quote, or bracket can cause a PHP error and prevent the site from loading. If you are changing a setting, update only the relevant line and preserve the surrounding syntax. When possible, test changes on a staging site first.
After editing, save the file and check the website, including the administration area. If an error appears, restore the backup or undo the change. If you are unsure what a setting does, ask your hosting provider or a WordPress developer before modifying it.
Protect the WordPress Configuration File
Because wp-config.php contains database credentials and other sensitive values, limit access to it. Use a strong hosting account password, enable two-factor authentication where available, and provide file access only to people who need it. Keep WordPress, plugins, themes, and server software updated, and avoid sharing the file or copying its contents into public support forums.
File permissions should be set according to your host’s guidance. The correct permissions vary based on the server configuration, ownership, and security tools in use. Avoid applying broad permissions such as allowing everyone to write to the file. If you are uncertain, ask the host to recommend a secure setting for your specific account.
Never test whether the file is protected by trying to expose its contents in a browser or by creating a public copy. If you suspect the credentials have been disclosed, contact your hosting provider, change the database password, and update the configuration using a trusted process.
Conclusion
The WordPress configuration file is named wp-config.php. In a standard installation, you will find it in the main WordPress directory alongside wp-admin, wp-content, and wp-includes. It may also be located one directory above the installation, or in a custom path set by your hosting provider.
Use your hosting file manager, FTP or SFTP client, or SSH access to locate the file, and confirm that you have the correct site before making changes. Since wp-config.php holds sensitive settings, back it up, edit it carefully, and keep it protected. If it is missing or the site’s directory structure is unclear, check with your host or administrator rather than creating a replacement.