I am trying to Remote port forward from Raspberry pi in my local network using ssh on my windows pc
ssh -R 5941:localhost:8000 [email protected]
So from the above command, I am trying to forward connections from port 5941 on Raspberry pi server (192.168.1.191) to port 8000 on my pc (localhost) which hosts a web server on port 8000
The above ssh command executes with no errors but when i try to access http://localhost:5941/ on Raspberry Pi (192.168.1.191) i get
ERR_EMPTY_RESPONSE
I have tried
$ sudo netstat -a | grep 5941
tcp 0 0 0.0.0.0:5941 0.0.0.0:* LISTEN
tcp6 0 0 [::]:5941 [::]:* LISTEN
ssh -R 5941:localhost:8000 [email protected] -v
I get thisdebug1: Remote connections from LOCALHOST:5941 forwarded to local address localhost:8000
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: network
debug1: console supports the ansi parsing
debug1: client_input_global_request: rtype [email protected] want_reply 0
debug1: Remote: Forwarding listen address "localhost" overridden by server GatewayPorts
debug1: remote forward success for: listen 5941, connect localhost:8000
debug1: All remote forwarding requests processed
and when i try to access http://localhost:5941/ on Raspberry Pi (192.168.1.191) i get this on ssh console
debug1: client_input_channel_open: ctype forwarded-tcpip rchan 3 win 2097152 max 32768
debug1: client_request_forwarded_tcpip: listen localhost port 5941, originator ::1 port 58122
debug1: getsockopt TCP_NODELAY: Invalid argument
debug1: connect_next: host localhost ([::1]:8000) in progress, fd=7
debug1: channel 1: new [::1]
debug1: confirm forwarded-tcpip
debug1: channel 1: connected to localhost port 8000
debug1: channel 1: free: ::1, nchannels 2
How should I further diagnose my problem ?
The solution to this is to put 127.0.0.1 instead of localhost
ssh -R 5941:127.0.0.1:8000 [email protected]
This forces ipv4 instead of ipv6, for some reason ssh port forwarding in windows fails to work on ipv6, I was able to work the same command with localhost on linux just fine.
I found the solution from this post here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With