0

I'm trying to forward all requests to a port on a remote server to a port I have opened on my local dev environment at localhost:5000.

I'm using the following command to make this happen, but it keeps failing with a timeout error:

ssh -nNT -R 9001:localhost:5000 root@<server ip>

# On another window...

curl https://<server ip>:9001/
curl: (7) Failed to connect to <server ip> port 9001: Operation timed out

I have established that

  • SSH is running on both client and server
  • I can login to localhost using ssh localhost
  • I can login to server using ssh root@<server ip>
  • If I curl localhost:9001 from remote server it does not time out. It returns expected response. @RobertRSeattle
  • This is the result of lsof -i :9001 on remote server
  COMMAND  PID USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
  sshd    1425 root    8u  IPv4 34175281      0t0  TCP *:9001 (LISTEN)
  sshd    1425 root    9u  IPv6 34175282      0t0  TCP *:9001 (LISTEN)

Can anyone tell me what I'm doing wrong?

  • Does it also time out if you curl localhost:9001 from the remote server? – RobertRSeattle Sep 9 at 20:52
  • @RobertRSeattle Good question! No, it does not. It returns the content of the url I expect. – picardo Sep 9 at 20:54
  • 1
    So I'd guess the server is blocking that port for incoming requests. What OS is it running? Is it running iptables? ifw? – RobertRSeattle Sep 9 at 21:02
  • Thanks for pointing me in the right direction! I figured out that the firewall on the server was blocking the port 9001. I had to run sudo ufw allow 9001 to make it work. – picardo Sep 9 at 21:04
1

I figured out that the firewall on the server was blocking the port 9001. I had to run

sudo ufw allow 9001

to make it work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.