Unable to connect to server (Error: Could not establish data connection: Connection refused)

Need help with FileZilla Server? Something does not work as expected? In this forum you may find an answer.

Moderator: Project members

Post Reply
Message
Author
spazstic
504 Command not implemented
Posts: 6
Joined: 2023-10-10 18:06

Unable to connect to server (Error: Could not establish data connection: Connection refused)

#1 Post by spazstic » 2023-10-10 18:54

Hi All,

I've been trying to figure this out for a few days now. Back in 2010ish I had FileZilla running and used it in college. I recall it being fairly easy to set up. Not so much this time. Hoping one of you can help.

When using the FTP tester, I keep getting the error:" Error: Could not establish data connection: Connection refused".
I feel like I'm so close. I can get the welcome message, I can log in, it just won't do the final connection.

Steps/troubleshooting:
1. Read FAQ and network setup guide. Searched the forums and tried many suggestions that were posted. No dice.
2. Custom port range 49152-65534. Entered my public IP address.
3. Added port forwarding in router. Disabled all firewall options in router. Note that in my TPlink router, "virtual server" = port forwarding.
4. Added firewall exemptions to Windows firewall. Tried specific ports at first, then changed to all ports.
5. Changed from port 21 to port 22.
6. Tried explicit FTP over TLS as well as insecure plain FTP.
7. Disabled windows firewall.

Interesting note - I set the port range in the router to 49152-65534 and I get an immediate "connection refused error" when using ftptest.net.
If I open the port range in the router to 1-65535, it will proceed until "Error: Could not establish data connection: Connection refused".

I've tried changing numerous settings within Windows and the router. Not sure what else I can do to resolve this. Any help would be GREATLY appreciated. Thank you!!

Code: Select all

Status: Resolving address of XX.XXX.XX.XX

Status: Connecting to XX.XXX.XX.XX

Warning: The entered address does not resolve to an IPv6 address.

Status: Connected, waiting for welcome message...

Reply: 220-FileZilla Server 1.7.3

Reply: 220-Please visit https://filezilla-project.org/

Reply: 220 Let's see if I can read this...

Command: CLNT https://ftptest.net on behalf of XX.XXX.XX.XX

Reply: 200 Don't care.

Command: AUTH TLS

Reply: 234 Using authentication type TLS.

Status: Performing TLS handshake...

Status: TLS handshake successful, verifying certificate...

Status: Received 1 certificates from server.

Status: cert[0]: subject='CN=filezilla-server self signed certificate' issuer='CN=filezilla-server self signed certificate'

Command: USER guest

Reply: 331 Please, specify the password.

Command: PASS **********************

Reply: 230 Login successful.

Command: SYST

Reply: 215 UNIX emulated by FileZilla.

Command: FEAT

Reply: 211-Features:

Reply: MDTM

Reply: REST STREAM

Reply: SIZE

Reply: MLST type*;size*;modify*;perm*;

Reply: MLSD

Reply: AUTH SSL

Reply: AUTH TLS

Reply: PROT

Reply: PBSZ

Reply: UTF8

Reply: TVFS

Reply: EPSV

Reply: EPRT

Reply: MFMT

Reply: 211 End

Command: PBSZ 0

Reply: 200 PBSZ=0

Command: PROT P

Reply: 200 Protection level set to P

Command: PWD

Reply: 257 "/" is current directory.

Status: Current path is /

Command: TYPE I

Reply: 200 Type set to I

Command: PASV

Reply: 227 Entering Passive Mode (XX,XXX,XX,XX,251,220)

Command: MLSD

Error: Could not establish data connection: Connection refused
 

Here's what I see in the log:

Code: Select all

2023-10-10T18:39:20.468Z << [FTP Session 213 49.12.121.47] 220-FileZilla Server 1.7.3
2023-10-10T18:39:20.468Z << [FTP Session 213 49.12.121.47] 220-Please visit https://filezilla-project.org/
2023-10-10T18:39:20.468Z << [FTP Session 213 49.12.121.47] 220 Let's see if I can read this...
2023-10-10T18:39:20.830Z >> [FTP Session 213 49.12.121.47] CLNT https://ftptest.net on behalf of xx.xx.xx.xx
2023-10-10T18:39:20.830Z << [FTP Session 213 49.12.121.47] 200 Don't care.
2023-10-10T18:39:21.199Z >> [FTP Session 213 49.12.121.47] AUTH TLS
2023-10-10T18:39:21.200Z << [FTP Session 213 49.12.121.47] 234 Using authentication type TLS.
2023-10-10T18:39:21.723Z >> [FTP Session 213 49.12.121.47] USER guest
2023-10-10T18:39:21.723Z << [FTP Session 213 49.12.121.47] 331 Please, specify the password.
2023-10-10T18:39:22.222Z >> [FTP Session 213 49.12.121.47] PASS ****
2023-10-10T18:39:22.222Z << [FTP Session 213 49.12.121.47 guest] 230 Login successful.
2023-10-10T18:39:22.587Z >> [FTP Session 213 49.12.121.47 guest] SYST
2023-10-10T18:39:22.587Z << [FTP Session 213 49.12.121.47 guest] 215 UNIX emulated by FileZilla.
2023-10-10T18:39:22.959Z >> [FTP Session 213 49.12.121.47 guest] FEAT
2023-10-10T18:39:22.959Z << [FTP Session 213 49.12.121.47 guest] 211-Features:
2023-10-10T18:39:22.959Z << [FTP Session 213 49.12.121.47 guest] 211 End
2023-10-10T18:39:23.329Z >> [FTP Session 213 49.12.121.47 guest] PBSZ 0
2023-10-10T18:39:23.329Z << [FTP Session 213 49.12.121.47 guest] 200 PBSZ=0
2023-10-10T18:39:23.699Z >> [FTP Session 213 49.12.121.47 guest] PROT P
2023-10-10T18:39:23.699Z << [FTP Session 213 49.12.121.47 guest] 200 Protection level set to P
2023-10-10T18:39:24.066Z >> [FTP Session 213 49.12.121.47 guest] PWD
2023-10-10T18:39:24.066Z << [FTP Session 213 49.12.121.47 guest] 257 "/" is current directory.
2023-10-10T18:39:24.436Z >> [FTP Session 213 49.12.121.47 guest] TYPE I
2023-10-10T18:39:24.436Z << [FTP Session 213 49.12.121.47 guest] 200 Type set to I
2023-10-10T18:39:24.804Z >> [FTP Session 213 49.12.121.47 guest] PASV
2023-10-10T18:39:24.804Z << [FTP Session 213 49.12.121.47 guest] 227 Entering Passive Mode (XX,XXX,XX,XX,239,216)
2023-10-10T18:39:25.121Z !! [FTP Session 213 49.12.121.47 guest] GnuTLS error -110 in gnutls_record_recv: The TLS connection was non-properly terminated.
2023-10-10T18:39:25.121Z == [FTP Session 213 49.12.121.47 guest] Client did not properly shut down TLS connection
2023-10-10T18:39:25.121Z >> [FTP Session 213 49.12.121.47 guest] MLSD
2023-10-10T18:39:25.122Z !! [FTP Session 213 49.12.121.47 guest] Control channel closed with error from source 0. Reason: ECONNABORTED - Connection aborted.
Attachments
Windows Firewall settings.JPG
Windows Firewall settings.JPG (335.62 KiB) Viewed 4554 times
Router Settings 1.JPG
Router Settings 1.JPG (241.44 KiB) Viewed 4554 times
Server GUI log.JPG
Server GUI log.JPG (412.7 KiB) Viewed 4554 times
Server settings 2.JPG
Server settings 2.JPG (154.48 KiB) Viewed 4554 times
Server settings 1.JPG
Server settings 1.JPG (121.88 KiB) Viewed 4554 times

spazstic
504 Command not implemented
Posts: 6
Joined: 2023-10-10 18:06

Re: Unable to connect to server (Error: Could not establish data connection: Connection refused)

#2 Post by spazstic » 2023-10-10 19:05

Also - I am able to connect to the server locally using another PC.

I can connect via ftp and ftpes. But not using sftp and ftps.

spazstic
504 Command not implemented
Posts: 6
Joined: 2023-10-10 18:06

Re: Unable to connect to server (Error: Could not establish data connection: Connection refused)

#3 Post by spazstic » 2023-10-10 19:54

Also, when connecting using the client, non-local, I get the following (using ftp or ftpes). Obviously it's talking to the server, there's just something preventing the connection. I suspect it's a firewall issue, but I can't tell from where. I've tried all the settings within my router and windows firewall. I do not have any additional firewalls beyond that.

Code: Select all

Status:	Connecting to XX.XXX.XX.XX:21...
Status:	Connection established, waiting for welcome message...
Status:	Initializing TLS...
Status:	TLS connection established.
Status:	Logged in
Status:	Retrieving directory listing...
Command:	PWD
Response:	257 "/" is current directory.
Command:	TYPE I
Response:	200 Type set to I
Command:	PASV
Response:	227 Entering Passive Mode (XX,XXX,XX,XX,212,85)
Command:	MLSD
Response:	150 About to start data transfer.
Error:	The data connection could not be established: ECONNREFUSED - Connection refused by server

User avatar
boco
Contributor
Posts: 26940
Joined: 2006-05-01 03:28
Location: Germany

Re: Unable to connect to server (Error: Could not establish data connection: Connection refused)

#4 Post by boco » 2023-10-10 20:08

First, don't use 22, it's reserved for SFTP (only FileZilla Pro Enterprise Server supports SFTP).

Second, did you also forward the complete Passive port range to the server PC? I can't see it for some reason.
No support requests over PM! You will NOT get any reply!!!
FTP connection problems? Please read Network Configuration.
FileZilla connection test: https://filezilla-project.org/conntest.php
FileZilla Pro support: https://customerforum.fileZilla-project.org

spazstic
504 Command not implemented
Posts: 6
Joined: 2023-10-10 18:06

Re: Unable to connect to server (Error: Could not establish data connection: Connection refused)

#5 Post by spazstic » 2023-10-10 20:38

boco wrote:
2023-10-10 20:08
First, don't use 22, it's reserved for SFTP (only FileZilla Pro Enterprise Server supports SFTP).

Second, did you also forward the complete Passive port range to the server PC? I can't see it for some reason.
Thanks, that makes sense regarding SFTP. I had read on a couple of forums that 22 fixed the issue others were having. I've reverted back to 21. Is 990 still required for FTP over TLS?

For the second part - I believe so. With tp-link, "virtual server" = port forwarding. I have set port 21 to forward to 1-65535 on my server PC. When I had it set to the custom port range (49152-65534) it would not connect at all.

I really appreciate your help. I've read countless responses you've given on this forum. Thank you!

spazstic
504 Command not implemented
Posts: 6
Joined: 2023-10-10 18:06

Re: Unable to connect to server (Error: Could not establish data connection: Connection refused)

#6 Post by spazstic » 2023-10-10 22:01

This is driving me nuts. I feel like it should be working.

An online port check shows 21 to be open (as expected).

On a remote client, I can connect via TLS. It begins to pull the directory listing, then throws an ECONNREFUSED error.

What's going on here?

Thanks in advance for any advice you can give. :)
Attachments
Client Side.JPG
Client Side.JPG (168.46 KiB) Viewed 4495 times

User avatar
boco
Contributor
Posts: 26940
Joined: 2006-05-01 03:28
Location: Germany

Re: Unable to connect to server (Error: Could not establish data connection: Connection refused)

#7 Post by boco » 2023-10-10 22:02

990 is only required for Implicit FTP over TLS, a deprecated, not recommended way to connect. The recommended Explicit FTP over TLS actually uses the same port as normal FTP, 21.

As for the forwards, you're doing it wrong. The forwards must be external to internal 1:1.

External 21 to internal 21, and External 49152-65534 to internal 49152-65534. Each and any port remapping will fail for FTP, it's very sensitive to that stuff. Oh, and FTP is old, you need only TCP.
No support requests over PM! You will NOT get any reply!!!
FTP connection problems? Please read Network Configuration.
FileZilla connection test: https://filezilla-project.org/conntest.php
FileZilla Pro support: https://customerforum.fileZilla-project.org

spazstic
504 Command not implemented
Posts: 6
Joined: 2023-10-10 18:06

Re: Unable to connect to server (Error: Could not establish data connection: Connection refused)

#8 Post by spazstic » 2023-10-10 22:12

boco wrote:
2023-10-10 22:02
990 is only required for Implicit FTP over TLS, a deprecated, not recommended way to connect. The recommended Explicit FTP over TLS actually uses the same port as normal FTP, 21.

As for the forwards, you're doing it wrong. The forwards must be external to internal 1:1.

External 21 to internal 21, and External 49152-65534 to internal 49152-65534. Each and any port remapping will fail for FTP, it's very sensitive to that stuff. Oh, and FTP is old, you need only TCP.
YES!!! I knew it had to be something stupid. Working great now. THANK YOU!!!

Post Reply