Warning: remote port forwarding failed for listen port 52698

77.2k Views Asked by At

I'm using SSH to access my university's afs system. I like to use rmate (remote TextMate), which requires SSH tunneling, so I included this alias in my .bashrc.

alias sshr=ssh -R 52698:localhost:52698 [email protected]

It has always worked until now.

5

There are 5 best solutions below

3
Rose Perrone On BEST ANSWER

I had another SSH connection open. I just needed to close that connection before I opened my SSH tunnel.

Further Explanation: Once one ssh connection has been established, subsequent connections will produce a message:

Warning: remote port forwarding failed for listen port 52698

This message is harmless, as the forward can only be set up once and one forward will work for all ssh connections to the same machine. The original ssh session that opened the forward will stay open when you exit the shell until all remote editing sessions are finished.

3
Mark Lakata On

I had the same problem. In order to find the port that is already open, you have to issue this command on the 'corn.myschool.edu' computer:

sudo netstat -plant  | grep 52698

And then kill all of the processes that come up with this (replace xxxx with the process ids)

sudo kill -9 xxxx

(UPDATED: changed the option to be -plant as it is a nice mnemonic)

0
Dmitry M. On

In my case, the problem was that the remote system didn't have DNS properly set up, and it couldn't even resolve its own hostname. Make sure you have a working DNS in /etc/resolv.conf at the remote system.

0
Lachlan Hunt On

I experienced this problem, but it was while connecting to a server on which I don't have sudo priviliges, so the top response suggesting runing sudo netstat ... wasn't feasible for me.

I eventually figured out it was because there were still instances of rmate running, so I used ps to list the running processes and then kill -9 pid (where pid is the process ID for rmate).

0
dxtr80 On

This solved my problem reported here as well. To avoid this notification "AllowTcpForwarding" should be enabled in SSH config.