Remote forwarding failure

While developing facebook applications I occasionally get this error while running rake facebooker:tunnel:start.

debug1: Remote connections from *:6300 forwarded to local address
localhost:3000
debug1: Entering interactive session.
debug1: remote forward failure for: listen 6300, connect
localhost:3000
Warning: remote port forwarding failed for listen port 6300

Unable to open remote port via ssh

There’s a couple of reasons for this. First up you might have your sshd config set up incorrectly, but that wasn’t the case for me. Instead – it’s when I have the tunnel open and I change wifi connections and the old connection seems to hang around on the server, preventing the new ssh connection from opening a port.

You can easily check what process is holding the port open on your server by using netstat:

[tomato:~]$ sudo netstat -ap | grep 6300
tcp6       0      0 [::]:6300               [::]:* LISTEN
18354/sshd: ben

Netstat results for port 6300 on my server.

Once you’ve found the hanging sshd process that is holding onto the port you want to tunnel with, you can kill it with extreme prejudice:

[tomato:~]$ kill 18354
[tomato:~]$

Goodbye useless sshd

You’re quite safe killing ssh daemons which are running as yourself, just make sure you don’t killall sshd, or you might find a bit difficult to log back in.

Which is another reason to use a virtual hosting provider, because they usually provide console log on – which is much harder to bork.


Leave a Reply