I'm trying to set up tunneling and I'm testing by trying to a ubuntu iso (torrent instead of http). On my machine I'm using

ssh -4 -g -N -D root@rpi_addr

I'm getting errors and not able to download anything

channel 14: open failed: connect failed: Connection refused

From my understanding -4 forces everything to be ip 4 (my isp doesn't offer ipv6), -g should allow connections from my server to me, -N means I don't want/need to execute any shell commands and -D is where the socks server should be at? I have a feeling this might be a UDP problem but I'm not sure. Especially since it's saying Connection refused

If it matters, my host pc is windows 10. I tried using ssh that comes with windows 10 and with git-bash. The server I'm connecting to is a raspberry pi

  • 1
    (1) "I'm getting errors" – When? Just after you invoke ssh? or when you try to use the proxy? (2) What are the errors from? From the ssh? (3) What program with what settings are you using to actually test the connection? (4) "-g should allow connections from my server to me" – If you mean "from the pi to the Windows 10" then possibly not in the way you mean. Are you sure you want a socks proxy? (5) Please read this: How to create a SOCKS proxy with ssh. Commented Apr 1, 2021 at 20:29
  • @KamilMaciorowski 1) when I start the torrent to download ubuntu. It downloads nothing and prints many of these. 2) The shell that I executed the ssh line on 3) qbittorrent, not sure why that would matter. 4) Does my line not allow both windows and linux to open ports to eachother? Commented Apr 1, 2021 at 22:46
  • (1) Connection refused means the SSH server could not connect to the requested address on the behalf of the SOCKS client. I guess it's not unusual when torrenting because some trackers or peers may no longer be at their former addresses. (3) I wanted to make sure the program can actually use SOCKS. Your statement about "connections from my server to me" made me suspect you were confusing things. (4) -g could allow other clients in your LAN to use the 7123 port of your local machine as a SOCKS proxy. I think -g is irrelevant in your case because you bind to anyway. Commented Apr 1, 2021 at 23:21
  • @KamilMaciorowski I'm not sure whats happening but I can browse websites just fine but not peer to peer Commented Apr 2, 2021 at 6:25

2 Answers 2


Say, you have a server, with SSH, and MySQL.

ssh -L 3336: root@rpi_addr

Then calling MySQL on your local host will be tunneled to rpi_addr's localhost interface... More here: https://linuxize.com/post/how-to-setup-ssh-tunneling/


If I understand your question correctly, you want the remote host to be able to use the SSH channel to access a SOCKS server and not the other way around. I think that you need to use the -R option for this kind of thing, not -D.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .