WordPress.org

Ready to get started?Download WordPress

Forums

Failed to connect to FTP Server localhost:21 (17 posts)

  1. MKSi
    Member
    Posted 2 years ago #

    Hey, everyone. I'm hoping to find answers to a problem I'm having.

    Problem: I keep getting this message "Failed to connect to FTP Server localhost:21" after inputting my Hostname, FTP Username and FTP Password.

    I put in:
    Hostname localhost
    FTP Username root
    FTP Password (the same password I use to log into our Linux server)

    Some background: My boss hosts his website on his own Linux server using OpenSUSE 12.1. After moving the wordpress files from my laptop to his Linux server, I tried to download a plugin. It brought me to that screen where I got that message.

    "Failed to connect to FTP Server localhost:21"

    I searched all over Google but haven't really found anyone who has fixed this problem.

    Is "localhost" good enough for Hostname?
    Should I be using the same user id and password as the one I use to log into server (or something else?

  2. For installation of plugins, themes, or automatic upodates, give this section a read.

    http://codex.wordpress.org/Updating_WordPress#Automatic_Update

    For Automatic Update to work, at least two criteria must be satisfied:

    (a) file ownership: all of your WordPress files must be owned by the user under which your web server executes. In other words, the owner of your WordPress files must match the user under which your web server executes.

    If the file ownership is correct then you shouldn't need to use FTP.

    But if you do need to use FTP...

    Is "localhost" good enough for Hostname?

    Apparently not. ;)

    Should I be using the same user id and password as the one I use to log into server (or something else?

    Check with your host. That's probably correct but it sounds like you are not running FTP on the same server that your WordPress is running on. Or it's not listening for FTP on localhost; your host provider would know.

  3. MKSi
    Member
    Posted 2 years ago #

    Hey, thanks. I really appreciate the reply and the link. After reading it, it sounds really helpful.

    Want to know if I'm understanding it correctly. It sounds like I need to download wordpress from the internet directly to our Linux server?

    That way the owner of "our WordPress files and the user under which our web server executes" will match?

    Because wordpress was originally downloaded and created on my macbook, then manually transferred to our Linux server

  4. Because wordpress was originally downloaded and created on my macbook, then manually transferred to our Linux server

    That can work fine, but the file permissions need to match the userid of the web server. When you transferred the files the ownership may not be quiet correct.

    For example, if you are running Ubuntu the user ID and GID is www-data. If WordPress runs as that user ID then when you attempt to install a plugin if the directories and files ownership are matching the webserver process, then it just works.

    If WordPress cannot write to those files and directories, it falls back to asking you for FTP credentials.

  5. MKSi
    Member
    Posted 2 years ago #

    ok

    Hmm, I'm thinking what if there are many file permissions that need to be changed.

    Question:
    If I downloaded and installed word press directly from our Linux server, would the file permissions match the userid of the web server?

    again, sorry for be a noob

  6. fkoosna
    Member
    Posted 2 years ago #

    Thanks for the information. I changed mine and it now works.

    The fast way to change it is to cd to the directory where you have the files where you first go, top root of your web pages.

    Then type in

    chown www-data *
    chown www-data */*
    chown www-data */*/*

    assuming yours is run under www-data, mine was apache.
    Then do that with keep adding a /* to the end the line, I had to go to chown www-data */*/*/*/*/*/*/*/*/* and got the error no such file or directory. This is the fastest way to change the own on them.

    I didn't do the chgrp to be apache, I just left it as it was.

    Also localhost will not work, you need to have an IP address that will resolve to your machine.

  7. MKSi
    Member
    Posted 2 years ago #

    Hey, fkoosna.

    I'm going to try that Monday and see if it works for me. Our server is using openSUSE 12.1.

  8. Double check the userid, I am 99.99% sure that OpenSUSE uses a different UID and GID than www-data.

  9. Double check the userid, I am 99.99% sure that OpenSUSE uses a different UID and GID than www-data.

  10. MKSi
    Member
    Posted 2 years ago #

    OK thanks Jan. I check it when I go back to work on Monday.

  11. MKSi
    Member
    Posted 2 years ago #

    When I tried to find the userid, I opened up a terminal application and typed "id -u root"

    It gave me "0" (the number zero)

  12. MKSi
    Member
    Posted 2 years ago #

    I did what fkoosna wrote. Except that I substituted www-data for mine.

    I had to go to chown 0 */*/*/*/*/*/*/*/*/*/*/*/*/* and got the error no such file or directory.

    Back to WordPress:
    Does it matter how I put my IP address into the hostname field?
    EX. ftp//:xxx.xxx.x.x or (without ftp) xxx.xxx.x.x or something else altogether?

  13. MKSi
    Member
    Posted 1 year ago #

    Finally got this fixed!

    I'm using a Linux server on Opensuse 12.1.

    Whatever ftp you are using make sure its on in "System Services (Runlevel)." Here's how to check.
    1. open "Yast"
    2. click "system" icon (on the left)
    3. click "System Services (Runlevel)"
    4. click "Expert Mode" (at the top)
    5. look for the ftp that you are using and select it. Mine was pure-ftpd.
    6. click "Start/Stop/Refresh" (at the bottom left).
    7. click "Start now ..."
    8. click "Set/Reset"
    9. click "Enable the service"
    10. click OK

    Then set it up in firewall
    1. open "Yast"
    2. click "Security and Users"
    3. click "Firewall"
    4. click "Allowed Services"
    5. click "Service to Allow"
    6. select your ftp
    7. click "Add"
    8. click "Next"
    9. click "Finish"

    Now for wordpress. Here is what worked for me:
    1. Log into your wordpress account
    2. go to the screen where it ask for your ftp info
    "Hostname:
    FTP Username:
    FTP Password:"
    3. For "Hostname" type in the static IP Address of your server, then a colon sign and then 21. Ex. 192.168.0.3:21
    4. For "FTP Username" type in your user name.
    The same one you use to login to server. BUT it should not be "root."
    5. For "FTP Password" type in the password to that user name.

    Ex.
    Hostname: 192.168.0.3
    FTP Username: serverusername
    FTP Password: passwordforserverusername

  14. pauleh
    Member
    Posted 1 year ago #

    Simple fix for "Failed to connect to FTP Server localhost:21" on Macintosh localhost.

    After much hair pulling and looking up dead-ends, here is what I did.

    In the terminal:

    sudo chown -R _www [folder/directory of my WP site]

  15. Victor Aboytes
    Member
    Posted 1 year ago #

    Hi everyone, some days ago I ran into the same problem when I was installing my first WordPress server under Linux Ubuntu Server 12. As many of you, I tried some procedures with no good results so I'd like to share how I fixed this issue:
    1.- Be sure that you have installed and configured 'vsftpd' in order to be able to FTP your server:
    sudo apt-get install vsftpd

    2.- Edit your vsftpd.conf file in order to disable anonymous connections and allowing your user to upload files to your server:
    sudo gedit /etc/vsftpd.conf
    By default anonymous connections are allowed. So, you should change the following line and have it in this way:
    anonymous_enable=NO
    Also, by default, local system users are not allowed to login to FTP server. To change this setting, you should uncomment the following line:
    #local_enable=YES
    In the same way, users are allowed to download files from FTP server, but they are not allowed to upload files to FTP server. To change this setting, you should uncomment the following line:
    #write_enable=YES
    Save the changes made and start the vsftpd daemon running the following command:
    sudo /etc/init.d/vsftpd start

    3.- If you noticed.. your /var/www/wordpress folder (also files and sub-folders) by default owns to root, so you have to change the ownership to you be able to modify, add, delete files into the
    Wordpress folder: (substitute 'username' by the user name you are using in linux)
    sudo chown -R username wordpress

    If you don't want WordPress ask for FTP details every time you install or delete plugins, add this lines into your /var/www/wordpress/wp-config.php file:

    define('FTP_HOST', 'localhost');
    define('FTP_USER', 'your_linux_Username');
    define('FTP_PASS', 'Your_linux_password');

    And that's it!!! If someone have questions regarding this procedure please write me at victoraboytes69@gmail.com
    Thks

  16. agionwp
    Member
    Posted 1 year ago #

    Alhamdulillah, there is an easy way to solve this problem as I found it here (http://www.chrisabernethy.com/why-wordpress-asks-connection-info)

    1. First, you need to know who user is running your webserver:
    Create a new blank file and paste this syntax in it.
    <?php echo(exec("whoami")); ?>
    Save the file in whatever title.

    2. Make the identified user above own the wordpress directory. Log in as root in your command prompt. Then execute this command:
    chown -R httpd: YOUR_WORDPRESS_DIR
    For example, if the wordpress directory is in /var/www/wp_dir, you can execute this:
    chown -R httpd: /var/www/wp_dir

    Finally, you can upload any themes into your webserver successfully.

  17. mikotron
    Member
    Posted 1 year ago #

    fkoosna, it worked for me! I chowned www-data * all the way to
    chown: cannot access*/*/*/*/*/*/*/*/*/*/*': No such file or directory

    I went back to update plugins and such on my dashboard and, presto!

    Thanks!!!

Topic Closed

This topic has been closed to new replies.

About this Topic