How to fix WordPress Updates (FTP Connection Information)

When I upgrade WordPress to a new version (here’s a link to the screenshot) or update WordPress plugins (here’s a link to the screenshot) I’m always asked for my FTP “Connection Information” which gets really annoying. I solved the problem easily, but there are a few other solutions that might work for you that I documented below.

Solution 1: Add FTP Info to wp-config (this worked for me!)

  • FTP into your host.
  • Navigate to your root folder of your domain
  • Edit the wp-config.php file
  • Towards the end of the file (before the ?>) add your FTP info like this (screenshot here):
    /** Lets me update without entering FTP info. */
    define(‘FTP_HOST’, ‘host’);
    define(‘FTP_USER’, ‘user’);
    define(‘FTP_PASS’, ‘pass’);
  • Change host to your FTP hostname. Change user to your FTP Username. Change pass to your FTP Password.
  • Save file, and now it should work.
  • I then physically moved my wp-config.php file up one folder so it can’t be accessed through the web. If you’re worried about wp-config vulnerabilities and wordpress security, then read this codex page to learn about hardening your wordpress installation.

Solution 2: FS_METHOD (this did not work for me unfortunately)

Edit: I already went with Solution 1. But if you want to try this Solution 2, make sure to read ktgeak’s useful comment at the bottom of this post.

Add this into your wp-config.php file towards the end of the file (before the ?>) and then save the file. Then it magically… could… work…

/** Lets me update without entering FTP info. */
define(‘FS_METHOD’, ‘direct’);

I found this solution here but it didn’t work for me – I ran into the problem of files and folders not being able to be created or deleted due to permission issues (Could not delete  /blah/blah/blah/). The easiest way to get around the issue is by turning PHP Safe Mode Off. So I did that but it still didn’t work. The next idea would be to CHMOD all folders and files to 777 but then that’s a real pain to do to plugins and all folders and files for a direct WordPress version upgrade. And I’m hesitant of having everything 777 and lazy to do specific files.

For those that want to know what the FS_METHOD does, here you go (from the editing wp-config wordpress page):

FS_METHOD forces the filesystem method. It should only be “direct”, “ssh”, “ftpext”, or “ftpsockets”. Generally, You should only change this if you are experiencing update problems, If you change it, and it doesnt help change it back/remove it, Under most circumstances, setting it to ‘ftpsockets’ will work if the automatically chosen method does not.

  • (Primary Preference) “direct” forces it to use Direct File I/O requests from within PHP, this is fraught with opening up security issues on poorly configured hosts, This is chosen automatically when appropriate.
  • (Secondary Preference) “ssh2” is to force the usage of the SSH PHP Extension if installed
  • (3rd Preference) “ftpext” is to force the usage of the FTP PHP Extension for FTP Access, and finally
  • (4th Preference) “ftpsockets” utilises the PHP Sockets Class for FTP Access.

Solution 2: Run wordpress as same user as apache user (I did not try this)

Seems very possible after speaking with my web hosting company! Read about this solution here.

Many hosting companies will run your apache instance using your user account, and all of your files will be owned by the same account. In those cases, you will probably not have the issue described here.

If your hosting company is running apache as a system user, and your files are owned by your own account, your only option may be to enter your FTP credentials here and allow WordPress to use FTP.

I spoke with my hosting company and they suggested I should consider using them to upgrade blogs for me using their scripts instead of doing this via an automatic update via the admin page. I’ll probably end up doing this since it’s a managed hosting solution anyway and then I won’t have to worry about updates.

They then said if I still want to do the upgrade from the admin page, they  can change the ownership of all the files from the current one to the apache user. But adding new plugins manually or installing new domains and wordpress installs, sounds like a lot of work to have them change the file ownership all the time.

If you have a better solution to this problem please post it in the comments section.