# Connection reset by peer (SSH, FTP)

## chy168

hi,

when I use ftp client to connect my FTP Server.

I can login it, but I type 'ls' to show the file list.

I'll get the err mesg and disconnected

```
netin:Connection reset by peer
```

when I put my file, i get 

```
netout: Connection reset by peer
```

when I connect to SSH, I'll get the error,too.

```
Read from remote host test.abc.ooxx.com: Connection reset by peer

Connection to test.abc.ooxx.com closed.
```

what happened on my Genoo ?  :Sad: 

thank you. :p

----------

## egberts

Most likely candidate of your problem is your firewall is dropping your FTP data connection.

As you recall, FTP is composed of two TCP sessions:

1.  Control - the ones that handles all your commands (LS, DIR, GET)

2.  Data - the ones that actually carries the content of the file (including directory listings)

Your firewall works well with #1.  But it is blocking #2.   

Try this again using 'passive', by doing this at your FTP prompt BEFORE doing any #2 related commands.

```
~ $ ftp ftp.redhat.com

Connected to ftp.redhat.com.

220 Red Hat FTP server ready. All transfers are logged. (FTP) [no EPSV]

Name (ftp.redhat.com:steve): anonymous

530 Please login with USER and PASS.

SSL not available

331 Please specify the password.

Password:

230 Login successful.

Remote system type is UNIX.

Using binary mode to transfer files.

ftp> passive

Passive mode on.

ftp> 
```

Please NOTE the word 'passive' used in above example.

If that works, then you have two choices:

1.  Ensure that all FTP sessions have 'passive' command done.

    # ftp -p ftp.redhat.com

2.  Adjust your firewall so that you let out more FTP-DATA TCP connections

----------

## chy168

hi egberts, I've tried your tips.

but, I got some strange error.

```
root@NB:/home/chy168/Desktop# ftp -p sun8.csie.thu.edu.tw

Connected to test.abc.ooxx.com

220 ProFTPD 1.2.10 Server (Welcome to FTP) [123.45.6.7]

Name (test.abc.ooxx.com:chy168):

331 Password required for chy168.

Password:

l230 User chy168 logged in.

Remote system type is UNIX.

Using binary mode to transfer files.

ftp> ls

227 Entering Passive Mode (123,45,6,7,129,23).

```

"sometimes" I log in the FTP and 'ls' all my files. I can get the whole list.

but after a few second, I cannot 'ls' my files again.

it will show : 

```
227 Entering Passive Mode (123,45,6,7,129,23).
```

and hang.

"sometimes" I log in my FTP and 'ls'.

I can get a part of file list, and it will tell me. 

```
Connection reset by peer
```

My ssh also has the same condition.

is it still a problem in my Firewall ?

what item in firewall should I adjust ?

thank you very much.. thank you ^^..

----------

## egberts

Need to know two things:

Are you running a NAT firewall?  That is, do you use private IP address such as 10..x.x.x or 192.168.x.x (or even 172.28.x.x)

Are you running over DSL?

----------

## chy168

 *egberts wrote:*   

> Need to know two things:
> 
> Are you running a NAT firewall?  That is, do you use private IP address such as 10..x.x.x or 192.168.x.x (or even 172.28.x.x)
> 
> Are you running over DSL?

 

Yes.

I'm in a NAT network, and I use private IP address.

This network has firewall.

----------

