WordPress Prompts for S/FTP Credentials on Local Development

The prompt for SFTP and FTP details means that you don’t have the right permissions to download or upgrade plugins or the WordPress core.

The most probable reason is that the ownership of your local files is incorrect, but it’s also potentially a permissions issue.

Find the Apache User and Set Ownership

The owner of the files in your project needs to be the Apache user. The easiest way to find out your Apache user is to run this command while the service is running.

1
ps aux | grep apache
ps aux | grep apache

Some common users are www or www-data. So now let’s update your project root. Let’s say it is /var/www/projectName and that our Apache user turned out to be www-data:

1
sudo chown -R www-data /var/www/projectName
sudo chown -R www-data /var/www/projectName

Now you can attempt the upgrade or install again. More than likely you are up and running, but if not let’s reset file permissions.

Reset Local File Permissions

1
sudo chmod -R 777 /var/www/projectName
sudo chmod -R 777 /var/www/projectName

Since you are on your local there is no security risk here. Just make sure you don’t pass these permissions on to the live site when you deploy.

In some limited hosting environments, you will also get this prompt on your live site. There isn’t a lot you can do here except get a better host, or deal with a slight inconvenience.

Discussion
Marc says:

The apache user in Ubuntu is typically “www-data”, like you mentioned, but in RHEL based servers like CentOS, it’s simply “apache”.

Also, I prefer the change of user for the files, rather than the permissions change because the permissions change is annoying to reverse and can be a big security issue, especially on a shared host.

I ran into the problem myself when installing WordPress MultiSite on my linux machine for development. The solution that worked for me (file permissions didn’t, I tried :\) was to add a line to my config file:

`define(‘FS_METHOD’,’direct’);`

Without that line in my config file, all plugin and theme install requests were met with a form asking for FTP info.

Leave a Reply