You are here: Home » Extending WordPress » How To Fix FTP Connection Error on Localhost WordPress

How To Fix FTP Connection Error on Localhost WordPress

by Dave Doolin on June 10, 2009 · 6 comments

(Reading time: 6 – 9 minutes)

Overcast and drizzling here in paradise, that is, the east side of San Francisco Bay. This is the second time it’s rained in June. It never rains in June here! Not since 1998 that I can remember. In any case, let’s see what else the day brings.

Since WordPress 2.8 is scheduled for release sometime today, let’s check out a copy of WordPress 2.8 from subversion, install it on localhost, and poke around a bit.

My handy instructions for 5 minute WordPress installation don’t work exactly the same when installing on locahost. I don’t have cPanel installed locally, so I had to create the MySQL database and database user manually using a cygwin shell window.

First look: no major changes obvious to me other than the spiffy theme browser. So, let’s install a new theme, right from the WordPress.org theme repository.

Uh oh… FTP Connection Information required.

FTP connection information required indicates permission problem on host

FTP connection information required indicates permission problem on host

The WordPress connection information is telling me I can’t upgrade because WordPress doesn’t have permission to write files new files on the host.

That’s not good, and it needs to be fixed, pronto.

This wasn’t a problem when I initially installed WordPress, because I manually copied the WordPress files to the correct location.

Short answer

Have your FTP information ready and type it into the form as required. You should have FTP account information as part of your web hosting account. If everything is working correctly, the installation should proceed without issue.

Longer story

When typing your information into the web form simply will not work, you need to investigate several problems:
Ensure your FTP account information actually is correct. If necessary, create a new FTP account with “known good” username and password. Make sure to test the new FTP account in an FTP client other than WordPress. Now try the above procedure again.

If you’re still having problems, check to ensure your directory permissions are set correctly. One way to check your permissions is to use the WP Security Scan plugin, which will scan your WordPress installation and let you know which file and directory (folder) permissions are correct, and which are incorrect.

By the way, if you’re finding this article useful, send an empty email to wp-weekend.ftpconnection@aweber.com to get more useful tips, tricks, lessons on WordPress, news on security updates, etc. You’ll the get the cutting edge stuff a couple of times per month. It’s spam-free, privacy protected, yadda yadda yadda. You’ll have to confirm to get in, opting out later is a click. Just an empty email to wp-weekend.ftpconnection@aweber.com does the trick.

What if you’re running on localhost?

I’m running on localhost, I shouldn’t need to provide FTP information. Let’s poke around on Google and see what we get… using “wordpress connection information” gives us two likely pages from wordpress.org (here, and here), and “Why WordPress Asks for Connection Info” from Chris Abernethy. You should read all three of these pages, and if you’re running on a remotely hosted server such as bluehost.com, these three links should be enough.

If you’re running on localhost, read on…

(or skip down to what to do on your hosted server)
Fire up a cygwin shell window and take a look. You could almost as easily do this using Windows cmd shell, but I prefer cygwin and bash.

File system ownership change fixing FTP connection error

File system ownership change fixing FTP connection error

See the top red box? One of these things is not like the other!

All the WordPress installations running on localhost run as Admistrators, but wp28 is running as my username “doolin.” How did that happen? Hard to say. Perhaps a slight change in how 2.8 installs itself. That’s a matter to dig into deeper in the future. Right now, we have other work to do.

Clearly, the ownership of the “wp28″ directory needs to be changed. Since I don’t remember exactly what the flag for recursive changes are using the “chown” command. It’s either “-r” or “-R” so let’s look it up first using the man page, as indicated by the blue arrow. The unix man page browser opens in a pager, when the pager closes, it advances one line in the shell; you don’t see the chown information in the screenshot.

Now that you have the correct information, issue the chown command as shown in the bottom red box.

All fixed!

But is it…?

One of my first tasks after installing a new WordPress blog is checking the security setup. It should be one of your first tasks as well. Downloading and activating Michael Torbert’s WP-Security shows us the following problems with respect to file system permissions:

Use WP-Security to check file system permissions

Use WP-Security to check file system permissions

That’s nasty. Now, since this installation of WordPress is running on localhost, it probably doesn’t matter all that much whether I fix them or not. But I should, and I will:

  1. Good habits are hard to make and easy to break. So just do it.
  2. Changing permissions is trivial using the bash shell from the cygwin command line. bluehost.com allows ssh access to a bash shell on the host, so I can use the exact same commands there in the future, if necessary.

When you get an FTP Connection error when upgrading or updating, block aside a little bit of time to dig into the problem, and prepare to learn a tiny bit of unix magic. It’s not difficult, and it will pay you back later.

Changing permissions on your web host

The easiest way to check your relevant permissions is to use the WP-Security plugin as mentioned above.

What I do when I find anything out of order is use the FileZilla FTP client to change the permissions to the correct values. There’s plenty of information on Google about how to do this, leave a comment if you want more explanation here.

If you’re an advanced user, check out Viper 007Bond’s explanation of new capabilities for file system handling in WordPress 2.8. (Hat tip Ricky Buchanan from the comments.)




Would you like more? Send me a letter...
"Hi Dave,
Website In A Weekend seems pretty cool. I'm serious about this WordPress and web stuff, and I'd like to keep up with it. My name is and my email address is . I'm comfortable with email newsletters. I know you will protect my privacy, and that I can unsubscribe at any time. "

{ 6 comments }

Scott Crevier July 8, 2009 at 9:43 pm

I get the “Connection Information” screen when attempting to upgrade a plugin automatically. I’m fine with providing the requested info, but it doesn’t work. And I’m quite sure I know why. The “Connection Information” screen doesn’t ask me what directory the web site is installed in. When I manually ftp to my site, it drops me into my home directory. I then change into the document_root of the web site I want to work on. I have a couple dozen web sites on this one account, all using the same ftp user. So how does Wordpress know what directory to change into? Can I set that somewhere? Does it assume that the home directory is also the document_root? Is this info documented somewhere?

Dr Wordpress! July 8, 2009 at 10:02 pm

Scott,

Each WordPress installation has a set of constants that are defined. For example, WP_PLUGIN_DIR is defined as the location on the filesystem where your plugin directory resides. This location is obtained using dirname(__FILE__) php function (IIRC, didn’t look it up). You can see where WP_PLUGIN_DIR is defined and used here:

http://phpxref.ftwr.co.uk/wordpress/nav.html?_functions/index.html

For more information, poke around the constants listing for the source.

I will also have a plugin available soon which you can use to display your paths within your admin area. Watch for it on the plugins page.

Ricky Buchanan October 24, 2009 at 5:04 pm

I was looking for a fix for the “wordpress asks for connection information” on localhost problem. Turned out what I had actually needed was here:
http://www.viper007bond.com/2009/05/07/wordpress-how-to-force-direct-filewrites-for-upgrades/
in the added last 3 lines of the post.

There’s suprisingly little information on that on the net. I’m running under XAMMP on OS X, just a test install of 2.9-rare.

r
Ricky Buchanan´s last blog ..Dictate News: Bluetooth, Mouse Control, and Discounts My ComLuv Profile

Dr Wordpress! October 25, 2009 at 9:38 am

@Ricky – Thanks for this excellent reference! I’ll do some work on this article this week.
Dr Wordpress!´s last blog ..7 Ways To Evaluate Blog Post Quality — Tuning your BS detector My ComLuv Profile

Xous November 3, 2009 at 7:45 pm

Hi, regarding author comment
“NOTE: June 18 2009. I’m still getting alot of traffic on this post… what is it that you’re looking for, exactly? Leave a comment, I’ll check into it if I can.”

I’ll tell you my exact problem.

1) Installed wordpress in a WAMP environment, that would be localhost. So somewhere you say that your hostname is ‘localhost’.
2) tried to upload the wp in a hosting, so I’ll have an address like ‘www.mysite.com’, BUT …. when I try to get to ‘www.mysite.com/wp-admin’, it forwards to:
http://localhost/wp-admin and says error…. and never can connect to the admin to change the value.

So that’s what basically I’m looking for, and probably what most users getting here are also looking for :P
Thanks in advance!
Jose

Dr Wordpress! November 5, 2009 at 6:50 pm

Jose, I don’t really get what your exact problem is here. The article deals with file system permissions instead of domain problems.
Dr Wordpress!´s last blog ..Twitter Redux – Making Sense of Social Media Madness My ComLuv Profile

Comments on this entry are closed.

Previous post:

Next post: