Today, we’ll show you how to go through the process of changing the FS_METHOD constant. No matter the reason you need to make this adjustment, we’ll walk you through the process so you can get back to the development projects you have on deck.
Let’s get started.
Check Out Our Video Guide On How To Change the Constant FS_METHOD
What Is FS_METHOD?
FS_METHOD is a WordPress constant that specifies how WordPress should write to the filesystem. By default, WordPress will try to use the Direct method, which writes files directly to the filesystem. This is the preferred method, as it’s the most efficient. However, if your server is not configured to allow direct file writes, WordPress will automatically try to use the FTP method instead.
The FS_METHOD works by specifying the method that WordPress should use:
If you change the FS_METHOD to something other than direct, you may need to enter your FTP credentials in order for WordPress to function properly.
Why Would I Need to Change FS_METHOD?
There are a few reasons why you might need to change the FS_METHOD constant:
Your server is not configured to allow direct file writes. In this case, you’ll need to specify an alternate method so that WordPress can function properly. Your host may have disabled the Direct method for security reasons. In this case, you’ll need to use an alternate method such as FTP.
You’re developing a WordPress plugin or theme that needs to write to the filesystem. By default, WordPress will not allow plugins or themes to write to the filesystem. However, you can change the FS_METHOD constant to ssh2, ftpext, or ftpsockets to allow plugins and themes to write to the filesystem.
What Does Changing FS_Method Do To My Server?
Changing the FS_METHOD constant will not have any negative impact on your server. However, if you change the constant to something other than direct, you may need to enter your FTP credentials in order for WordPress to function properly.
The “Connection Information” Error
This is the error that may cause you to want to change the FS_METHOD:
“To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.”
If you see this error, it means that WordPress cannot write to the filesystem. This can be caused by a number of factors, but the most common cause is that your server is not configured to allow direct file writes. Specifically, it can’t write to wp-content, usually due to a web hosting setting.
You can always take a look at what the Kinsta APM tool has to say about the issue as well. This performance monitoring tool can help you to debug slow database queries, requests, and other performance-related issues.
How To Set the Constant FS_METHOD in WordPress
The primary way to set the constant FS_METHOD is to add a code snippet to your wp-config.php file.
Before we get to our walkthrough of that process, it’s important to note that not every hosting server will allow you to access your site’s wp-config.php file. In these cases, you’ll need to take an alternative route to make this change.
- Ask Your Host to Make the Change for You: If your host provides a quality service you like, but you just need this one change made, your best bet is to ask your host to make the change for you. Many hosts will be happy to oblige, and it’s always worth asking.
- Switch Hosts: It may sound harsh but if you’re running into too many issues with your current host, it may be time to switch hosts. A quality WordPress host will make sure that you don’t run into these types of problems in the first place, and if you anticipate this won’t be the last time you need wp-config.php access, it might be time to seek out hosting elsewhere.
With these caveats out of the way, let’s discuss how to set the FS_METHOD constant yourself.
1. Make a Backup of Your Site
Any time you make changes to your wp-config.php file, you should first make a backup of your site. This will ensure that you can quickly revert any changes if something goes wrong.
There are a number of ways to create a WordPress backup, but we’ll always suggest doing so using MyKinsta. MyKinsta makes it easy to create a WordPress backup with just a few clicks. You can then easily restore your site if something goes wrong.
2. Connect to Your Site Using FTP
To get started, log in to MyKinsta to get your FTP login credentials. To access these, simply navigate to your site dashboard in MyKinsta, and then click on Sites > Sitename > Info and copy everything under the SFTP/SSH heading, including your Hostname, URL, username, password, and port.
In our example, we’re using Cyberduck:
You can also experiment with making changes like these on a local server first. DevKinsta will always be our go-to local WordPress development environment. And best of all? It’s free.
3. Download the wp-config.php File
Once you’re connected to your site using FTP, navigate to the root directory of your WordPress install. This is usually the /public_html/ directory.
Next, locate the wp-config.php file and download it to your computer.
4. Add FS_METHOD to the wp-config.php File
Within the wp-config.php file, look for a line that says:
* That's all, stop editing! Happy blogging. */
Just above this line, add the following code:
Save Your Changes and Upload the wp-config.php File
Once you’ve added the code to your wp-config.php file, save it and upload it back to your server.
And that’s it!
Is It Safe to Change FS_METHOD to Direct?
Generally speaking, yes, it’s safe to change FS_METHOD to direct. However, as with any change you make to your WordPress site, we always recommend backing up your site first. This will ensure that you can quickly revert any changes if something goes wrong.
In most cases, changing FS_METHOD to direct will not cause any problems. However, if you’re using a security plugin like Sucuri or Wordfence, they may detect the change and think that your site has been hacked. If this happens, simply whitelist the IP address that you’re using to make the change and everything should go back to normal.
Additionally, as mentioned previously, some WordPress hosting companies do not allow you to change FS_METHOD to direct. In this case, you’ll need to either switch hosts or use a different method to update your WordPress plugins and themes.
Lastly, security concerns do exist on some shared servers. If you’re using shared WordPress hosting, we recommend reaching out to your host before changing FS_METHOD to direct.
If you’re looking for a WordPress host that makes it easy to update your WordPress site, we recommend MyKinsta. MyKinsta uses the Google Cloud Platform, which offers SSH access by default on all plans. This means you can easily change the FS_METHOD constant to direct without having to worry about your host blocking the change.
Additionally, MyKinsta comes with a built-in WordPress backup solution so that you can quickly restore your site if something goes wrong. MyKinsta also uses server-level caching, which can speed up your WordPress site.
So there you have it – a step-by-step guide on how to change the FS_METHOD constant. We hope you found this guide helpful. And remember, if you need a well-rounded hosting plan that includes backups, a staging environment, and easy-access features, MyKinsta is your best bet.