My Scenario

I have a remote server( where I am running a python django webserver on port 8008. However, the remove server is only allowing ssh port 32686, which means that I cannot directly access remote server at port 8008 to view the webserver. This is why I am local port forwarding through ssh so that I can access remote server port 8008 from my local host port 8355(some random port number).

SSH command(problematic)

Looking up the guides on google, I came up with the following ssh command for my local port forwarding setup.

ssh -L 8008: someuser@ -p 32686

while ssh login worked, I cannot access the webserver from local host through port 8355. Instead, the console showed the following error.

channel 3: open failed: connect failed: Connection refused

Fixed ssh command

After some more googling and internal reflection, I cam up with the correct ssh command.

ssh -L 8008: someuser@ -p 32686

When I ssh login using this command, I can now access the webserver in remote host through accessing local host port 8355.

The only difference is the remote host ip address format inside local port option definition. I think if we use the public ip of the remote host(, then it will forward packets from local host to the “outside” of remote host’s port 8008 which is, as I mentioned earlier unavailable. By changing the public remote host ip address to “”, I believe it is notifying remote host’s sshd that the incoming packets do not need to be redirected to the “outside” of port 8008 but rather process it internally and redirect it to the “inside” of port 8008 right away. This way it will not be blocked by the firewall.


radu · October 18, 2022 at 1:15 am

Thanks man! This helped

Bu · May 19, 2023 at 8:00 pm

Thanks Bro!!!!
I spent a lot of time and only you could help me

Michael · August 7, 2023 at 6:48 pm

This worked!!! You are awesome!

Leave a Reply

Your email address will not be published.