Mohammedz.com

For Linux and Shell scripting.

FTP not working….. Connection closed by foreign host.

Leave a comment


My FTP service is not working. When I try telneting to ftp port, it gets closed by foreign host soon after connecting.

-bash-3.1# telnet localhost 21
Trying 127.0.0.1…
Connected to localhost (127.0.0.1).
Escape character is ‘^]’.
Connection closed by foreign host.
-bash-3.1#

Solution
***********
The server is having Plesk control panel installed. So, ftp service is proftp which is started with xinetd. So, restarted xinetd and check if ftp is listening on port 21.

-bash-3.1# netstat -plan |grep 21
tcp 0 0 0.0.0.0:106 0.0.0.0:* LISTEN 2173/xinetd
tcp 0 0 0.0.0.0:8880 0.0.0.0:* LISTEN 3221/httpsd
tcp 0 0 0.0.0.0:465 0.0.0.0:* LISTEN 2173/xinetd
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 2173/xinetd

Yes, it’s listening and xinetd didn’t show any errors. But, still FTP connection is in the old stated……Connection closed by foreign host.

Just check /etc/xinetd.d/ftp_psa to see how ftp service is getting started and started it manually. Hmm…….it shows errors now :(.

root@~#/usr/sbin/in.proftpd -c /etc/proftpd.conf
– IPv4 getaddrinfo ‘your.hostname.com’ error: Name or service not known
– warning: unable to determine IP address of ‘your.hostname.com’
– error: no valid servers configured
– Fatal: error processing configuration file ‘/etc/proftpd.conf’
root@~#

The hostname entry “your.hostname.com” was missing in /etc/hosts.
root@~#hostname
your.hostname.com
root@~#hostname -i
hostname: Unknown host
root@~#

So, added “your.hostname.com” to /etc/hosts and restarted xinetd service. That resolved the issue.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.