FTP connection refused by server

33 posts / 0 new
Last post
#1 Wed, 01/04/2012 - 07:27
nemezya

FTP connection refused by server

Hi everyone,

I just made a fresh Virtualmin installation on a nude Debian 6. I followed the tutorial to create a new FTP user but I get the "ECONNREFUSED - Connection refused by server" message.

My user name is "user1" on domain "test.com". The given FTP login (user1.test) doesn't work.

Any idea ?

Thanks.

Wed, 01/04/2012 - 11:11
andreychek

Howdy,

A connection refused error means that there's a problem with either the FTP service, or with a firewall blocking access to it.

Is your server running behind a NAT router, or other firewall? If so, you'd need to make sure you setup access to FTP on your server.

Also, does your ISP allow access to FTP? Some ISP's block certain ports, you'd want to make sure your ISP isn't blocking the FTP port.

Lastly -- you may want to make sure that the FTP service is running. You can do that by running this command:

netstat -an | grep :21

Tue, 03/15/2016 - 17:22
gezginci
gezginci's picture

in same status i dont have any messages :((

w8@hedefsunucu:~$ sudo netstat -an | grep :21 w8@hedefsunucu:~$

Tue, 03/15/2016 - 20:19
andreychek

Howdy,

It sounds like the FTP service may not be running in your case. If you restart the FTP service, does that resolve the issue you're seeing?

-Eric

Tue, 03/15/2016 - 23:24
gezginci
gezginci's picture

no... i restart many times... my /etc/hosts 127.0.0.1 localhost.localdomain localhost 95.9.190.95 hedefsunucu.hedefparca.com hedefsunucu

sudo service proftpd status: ● proftpd.service - LSB: Starts ProFTPD daemon Loaded: loaded (/etc/init.d/proftpd) Active: active (running) since Wed 2016-03-16 00:38:10 EET; 5h 44min ago Process: 455 ExecStart=/etc/init.d/proftpd start (code=exited, status=0/SUCCESS) CGroup: /system.slice/proftpd.service └─572 proftpd: (accepting connections)

Wed, 03/16/2016 - 01:06
gezginci
gezginci's picture

telnet localhost 21 Trying ::1... Trying 127.0.0.1... telnet: Unable to connect to remote host: Connection refused

Wed, 03/16/2016 - 01:12
gezginci
gezginci's picture

w8@hedefsunucu:~$ sudo proftpd --configtest Checking syntax of configuration file 2016-03-16 08:11:21,225 hedefsunucu.hedefparca.com proftpd[3945]: mod_dso/0.5: module 'mod_sftp.c' already loaded Syntax check complete.

Wed, 03/16/2016 - 04:00
coderinthebox

hedefparca.com is not registered, your configuration might be using this as a default hence it fails.

I am not 100% sure but you need to check if Proftp is running by using service proftpd status

I am not 100% sure on the command since I am not using debian. If proftpd is running, it is on another port and the reason why netstat -an | grep :21 return null.

Base on experience, proftpd only ask me for the username in this format.. username and not username.domain

Visit me at coderinthebox.com

Wed, 03/16/2016 - 16:30
gezginci
gezginci's picture

i use an other domain... i write it just for i do not make advirtasement...

service proftpd status ● proftpd.service - LSB: Starts ProFTPD daemon Loaded: loaded (/etc/init.d/proftpd) Active: active (running) since Wed 2016-03-16 00:38:10 EET; 5h 44min ago Process: 455 ExecStart=/etc/init.d/proftpd start (code=exited, status=0/SUCCESS) CGroup: /system.slice/proftpd.service └─572 proftpd: (accepting connections)

sudo proftpd --configtest Checking syntax of configuration file 2016-03-16 08:11:21,225 hedefsunucu.hedefparca.com proftpd[3945]: mod_dso/0.5: module 'mod_sftp.c' already loaded

maybe problem "mod_dso/0.5: module 'mod_sftp.c' already loaded"....

Wed, 03/16/2016 - 17:25
KristofM

I just wanted to chime in that I have the same problem on a fresh Debian 8 box. ProFtpd itself reports it's running but there is no process listening in on port 21. Fresh install with 0 changed settings to proftpd. (I double checked and it's configured for port 21)

sudo service proftpd status

kristof@vps:/tmp$ sudo service proftpd status
● proftpd.service - LSB: Starts ProFTPD daemon
   Loaded: loaded (/etc/init.d/proftpd)
   Active: active (running) since Wed 2016-03-16 23:01:22 CET; 8min ago
  Process: 11992 ExecStop=/etc/init.d/proftpd stop (code=exited, status=0/SUCCESS)
  Process: 12011 ExecStart=/etc/init.d/proftpd start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/proftpd.service
           └─12018 proftpd: (accepting connections)

Mar 16 23:01:22 vps proftpd[12011]: Starting ftp server: proftpd2016-03-16 23:01:22,644 vps proftpd[12017]: mod_dso/0.5: module 'mod_sftp.c' already loaded
Mar 16 23:01:22 vps proftpd[12011]: .

Output of netstat -an | grep :21

-no output-

Output of netstat -an

kristof@vps:/tmp$ netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.1:11000         0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:953           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:20000           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:38087           0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:587             0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:110             0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:783           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:143             0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:10000           0.0.0.0:*               LISTEN
tcp        0      0 37.97.153.139:53        0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0    448 37.97.153.139:22        178.119.154.34:54259    ESTABLISHED
tcp6       0      0 :::25                   :::*                    LISTEN
tcp6       0      0 ::1:953                 :::*                    LISTEN
tcp6       0      0 :::443                  :::*                    LISTEN
tcp6       0      0 :::587                  :::*                    LISTEN
tcp6       0      0 :::2222                 :::*                    LISTEN
tcp6       0      0 :::110                  :::*                    LISTEN
tcp6       0      0 ::1:783                 :::*                    LISTEN
tcp6       0      0 :::143                  :::*                    LISTEN
tcp6       0      0 :::111                  :::*                    LISTEN
tcp6       0      0 :::80                   :::*                    LISTEN
tcp6       0      0 :::45137                :::*                    LISTEN
tcp6       0      0 :::53                   :::*                    LISTEN
tcp6       0      0 :::22                   :::*                    LISTEN
tcp6       0      0 37.97.153.139:80        80.69.67.10:61920       TIME_WAIT
udp        0      0 0.0.0.0:606             0.0.0.0:*
udp        0      0 127.0.0.1:616           0.0.0.0:*
udp        0      0 0.0.0.0:43847           0.0.0.0:*
udp        0      0 0.0.0.0:24009           0.0.0.0:*
udp        0      0 0.0.0.0:20000           0.0.0.0:*
udp        0      0 0.0.0.0:10000           0.0.0.0:*
udp        0      0 37.97.153.139:53        0.0.0.0:*
udp        0      0 127.0.0.1:53            0.0.0.0:*
udp        0      0 37.97.153.139:53        0.0.0.0:*
udp        0      0 127.0.0.1:53            0.0.0.0:*
udp        0      0 0.0.0.0:68              0.0.0.0:*
udp        0      0 0.0.0.0:111             0.0.0.0:*
udp6       0      0 :::606                  :::*
udp6       0      0 :::33422                :::*
udp6       0      0 :::52363                :::*
udp6       0      0 :::53                   :::*
udp6       0      0 :::53                   :::*
udp6       0      0 :::111                  :::*
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ACC ]     STREAM     LISTENING     75273    /var/run/clamav/clamd.ctl
unix  2      [ ]         DGRAM                    8226     /run/systemd/journal/syslog
unix  2      [ ACC ]     STREAM     LISTENING     46894    /var/run/dovecot/stats
unix  2      [ ACC ]     STREAM     LISTENING     46899    /var/run/dovecot/ssl-params
unix  2      [ ACC ]     STREAM     LISTENING     46901    /var/run/dovecot/login/ssl-params
unix  2      [ ACC ]     STREAM     LISTENING     46905    /var/run/dovecot/replicator
unix  2      [ ACC ]     STREAM     LISTENING     46909    /var/run/dovecot/replication-notify
unix  2      [ ACC ]     STREAM     LISTENING     46912    /var/run/dovecot/login/pop3
unix  2      [ ACC ]     STREAM     LISTENING     46918    /var/run/dovecot/log-errors
unix  2      [ ACC ]     STREAM     LISTENING     46922    /var/run/dovecot/ipc
unix  2      [ ACC ]     STREAM     LISTENING     46924    /var/run/dovecot/login/ipc-proxy
unix  2      [ ACC ]     STREAM     LISTENING     78671    /var/run/mysqld/mysqld.sock
unix  2      [ ACC ]     STREAM     LISTENING     46928    /var/run/dovecot/indexer-worker
unix  2      [ ACC ]     STREAM     LISTENING     46932    /var/run/dovecot/indexer
unix  2      [ ACC ]     STREAM     LISTENING     46934    /var/run/dovecot/login/imap
unix  2      [ ACC ]     STREAM     LISTENING     46936    /var/run/dovecot/imap-urlauth-worker
unix  2      [ ACC ]     STREAM     LISTENING     46938    /var/run/dovecot/token-login/imap-urlauth
unix  2      [ ACC ]     STREAM     LISTENING     46940    /var/run/dovecot/imap-urlauth
unix  2      [ ACC ]     STREAM     LISTENING     46946    /var/run/dovecot/doveadm-server

In Webmin -> servers -> Proftpd server, proftpd is running (only stop button is available) also in Webmin -> others -> system and server status, the status is reported running

I couldn't find any logged errors in /var/log/messages and /var/log/proftpd/:

kristof@vps:/tmp$ sudo tail /var/log/proftpd/*
==> /var/log/proftpd/controls.log <==

==> /var/log/proftpd/proftpd.log <==
2016-03-16 21:32:16,622 vps proftpd[29756] vps.smart-soft.be: ProFTPD 1.3.5 (stable) (built Tue May 19 2015 11:09:58 UTC) standalone mode STARTUP
2016-03-16 22:34:50,867 vps proftpd[29756] vps.snipped.com: ProFTPD killed (signal 15)
2016-03-16 22:34:50,867 vps proftpd[29756] vps.snipped.com: ProFTPD 1.3.5 standalone mode SHUTDOWN
2016-03-16 22:34:54,066 vps proftpd[8869] vps.snipped.com: ProFTPD 1.3.5 (stable) (built Tue May 19 2015 11:09:58 UTC) standalone mode STARTUP
2016-03-16 23:01:21,580 vps proftpd[8869] vps.snipped.com: ProFTPD killed (signal 15)
2016-03-16 23:01:21,581 vps proftpd[8869] vps.snipped.com: ProFTPD 1.3.5 standalone mode SHUTDOWN
2016-03-16 23:01:22,646 vps proftpd[12018] vps.snipped.com: ProFTPD 1.3.5 (stable) (built Tue May 19 2015 11:09:58 UTC) standalone mode STARTUP
2016-03-16 23:18:10,959 vps proftpd[12018] vps.smart-soft.be: ProFTPD killed (signal 15)
2016-03-16 23:18:10,960 vps proftpd[12018] vps.snipped.com: ProFTPD 1.3.5 standalone mode SHUTDOWN
2016-03-16 23:18:11,010 vps proftpd[13042] vps.snipped.com: ProFTPD 1.3.5 (stable) (built Tue May 19 2015 11:09:58 UTC) standalone mode STARTUP
Wed, 03/16/2016 - 17:28
gezginci
gezginci's picture

KristofM, i exactly live same problem... it looks like Debian 8 problem because my laptop also Debian 8 and I take telnet localhost 21    telnet: Unable to connect to remote host: Connection refused

Wed, 03/16/2016 - 17:40
gezginci
gezginci's picture

I found a solution:

w8@hedefsunucu:~$ ftp localhost 2222
Connected to localhost.localdomain.
SSH-2.0-mod_sftp/0.9.9
ftp> exit

this means connect with SFTP... i connected my server with SFTP....

Wed, 03/16/2016 - 20:35 (Reply to #12)
coderinthebox

That was very strange and I think eric was right, they may have changed the default config

Visit me at coderinthebox.com

Thu, 03/17/2016 - 01:48 (Reply to #13)
KristofM

Wow, thanks! SFTP works indeed.

Strange though as in /etc/proftpd/proftpd.conf port 21 is configured. In /etc/proftpd/conf.d/sftpd.conf however port 2222 is indeed configured also.

Wed, 03/16/2016 - 19:11
andreychek

I have a suspicion that the new FTP config that they rolled out not only enabled SFTP, but also (I think inadvertantly) disabled standard FTP in the process.

I'll talk to Joe about that, but the solution in the meantime would be to either use SFTP on port 2222, or to edit /etc/proftpd/proftpd.conf, and disable the sftp portion in there.

-Eric

Thu, 03/24/2016 - 03:02 (Reply to #15)
metalab

I had this exact problem on a Debian 8. ftp stopped working after an update.

proftpd was running but not listening on port 21. Commented out these lines in /etc/proftpd/modules.conf.

#LoadModule mod_sftp.c
#LoadModule mod_sftp_pam.c

Restarted proftpd. ftp on port 21 working again :-)

Thanks.

-- Martin

Thu, 03/31/2016 - 21:37 (Reply to #16)
dowell22

Can confirm this is also the situation on a fresh install on Centos 6.

Tue, 05/03/2016 - 18:21 (Reply to #17)
vincellc

Confirming that this still the situation on Debian 8 with latest packages.

Seems deliberate to disable insecure FTP connections but caused a lot of confusion when attempting to enable FTP over TSL.

Mon, 05/23/2016 - 05:35 (Reply to #18)
homzon

Same here, disabling these two lines and restarting had no effect !

#LoadModule mod_sftp.c
#LoadModule mod_sftp_pam.c

Any other solution to get around this problem ?

Thu, 06/02/2016 - 06:15
anybug

same here, on two fresh install of Debian Jessie 8 and Virtualmin 5.03. proftpd service is running but nothing is listening on port 21 and the more surprising: even if I disable mod_sftp.c and mod_sftp_pam.c from /etc/proftp/modules.conf:

#LoadModule mod_sftp.c
#LoadModule mod_sftp_pam.c

proftpd still listens on 2222 port (proftpd service obviously restarted), that's weird. i'll keep you updated if i find a workaround

Tue, 06/07/2016 - 01:57
Diabolico
Diabolico's picture

Did you try to check etc/proftpd.conf and if you have comment out:

LoadModule mod_sftp.c
<IfModule mod_sftp.c>

    SFTPEngine on
    Port 2222
    SFTPLog /var/log/proftpd/sftp.log

    SFTPHostKey /etc/ssh/ssh_host_rsa_key
    SFTPHostKey /etc/ssh/ssh_host_dsa_key
.... (could be more lines and you must comment out all of them)

Restart ProFTPd and see if it works and dont forget to check iptables for port 21 and close 2222.

- I often come to the conclusion that my brain has too many tabs open. -
Failing at desktop publishing & graphic design since 1994.

Mon, 06/06/2016 - 10:25 (Reply to #21)
anybug

thanks for the tip, it's workin now i have fully disabled sftpd module: actually i have commented this line in etc/proftpd.conf: Include /etc/proftpd/conf.d/ as there's only one file (sftpd.conf) in etc/proftpd.conf/conf.d

#Include /etc/proftpd/conf.d/

proftp is now listening on 21 port after service restart :)

EDIT: as you said, you can comment all lines in /etc/proftpd/conf.d/sftpd.conf if you don't want to comment #Include /etc/proftpd/conf.d/ in etc/proftpd.conf,

#LoadModule mod_sftp.c
<IfModule mod_sftp.c>
    #SFTPEngine on
    #Port 2222
    #SFTPLog /var/log/proftpd/sftp.log
    #SFTPHostKey /etc/ssh/ssh_host_rsa_key
    #SFTPHostKey /etc/ssh/ssh_host_dsa_key
    #SFTPAuthorizedUserKeys file:~/.sftp/authorized_keys
    #SFTPCompression delayed
</IfModule>

it also works

Tue, 06/07/2016 - 02:06
Diabolico
Diabolico's picture

Honestly i dont know why would you disable SFTP when is much more secure than FTP. If i were you i would bring back SFTP, change from 2222 to something like 10000>n<65535 (dont forget iptables) and close port 20/21.

- I often come to the conclusion that my brain has too many tabs open. -
Failing at desktop publishing & graphic design since 1994.

Thu, 06/09/2016 - 08:56
anybug

i agree with you: i'd rather force my customers using SFTP or SSH instead of unsecured FTP but some of them asked me for it so...

Thu, 06/09/2016 - 14:34
Diabolico
Diabolico's picture

You dont even need to force anything just tell them the SFTP port and SFTP protocol, everything else can stay as it is.

- I often come to the conclusion that my brain has too many tabs open. -
Failing at desktop publishing & graphic design since 1994.

Fri, 06/10/2016 - 04:58
anybug

some customers aren't flexible: they need FTP protocol and they want to you use it as standard protocol for their transfers

Fri, 07/01/2016 - 14:47 (Reply to #26)
unborn
unborn's picture

as you said before: i agree with you: i'd rather force my customers using SFTP or SSH instead of unsecured FTP but some of them asked me for it so... ...so say no. if they insist on unsecured file transfers and you really care then perhaps they are not right customers for you..

Configuring/troubleshooting Debian servers is always great fun

Tue, 10/25/2016 - 03:22
horaceng

sorry, transfering large amount of files through sftp does increase server and client load, not to mention i'm pumping more than 10TB data each day. I don't know why they broke the FTP after the update, it just doesn't make sense and it did cost me for the trouble.

Tue, 10/25/2016 - 06:56 (Reply to #28)
unborn
unborn's picture

hey mate, what distro you are on? I mean what linux you running on that server they breached into? ...perhaps it was only weak password setup by one of your clients..

Configuring/troubleshooting Debian servers is always great fun

Tue, 02/07/2017 - 20:09
oranjbox

I'm having this same issue. Is there a way to correct it so I can transition customers away from FTP and onto SFTP without being abrupt?

Thu, 10/18/2018 - 00:29
johncarter2679

Hello. I was also in the same problem with my Android Smartphone FTP server, first of all, I think this is the problem with my phone but when I change all the settings and also update the firmware and all the software related to wireless connection but the problem persists with me. then I found that there is an error in my Router network that I use to connect with my Computer to done FTP. I fix my IP address and server error of my Router by following Linksys Support. So if you have the same try to check your router or your other wireless network's device to make FTP.

Mon, 01/28/2019 - 09:22
homzon

Hey !

I've got the same issue today, everything was working fine for more than a year on port 21. But all of a sudden every request got rejected on port 21, sftp on 2222 was fine however.

I fixed it by disabling sftp bu commenting everything in /etc/proftpd/conf.d/sftpd.conf

Tue, 01/29/2019 - 04:26
Jfro

Mainly because of encryption ciphers and protocols versions and so on.

Updates must be at both sides for newer or changed , if mismatched or not supported then also probelems!

Topic locked