I forwarded a port from a remote server (which has Tomcat running on it) to a local port on my machine.

Say, if the remote server address is http://myremoteserver.com:8080, I forwarded the port to localhost this way:

ssh -L 8080:myremoteserver.com:8080 -N watson

Note: Access to myremoteserver is possible only through watson.

After forwarding, if I run localhost:8080 on my browser, I can see the output. But if I try to access this localhost from any other machine on my network (DNS of localhost is server1) through browser, say server1:8080, it does not load at all.

Strangely, if I run tomcat on localhost (instead of port forwarding through ssh), and access it through browser from another machine on network, server1:8080, it works.

Please help. I thought it has to do something with iptables; but it doesn't work even after turning it off.


Try this:

ssh -L *:8080:myremoteserver.com:8080 -N watson

excerpt from man ssh for option -L:

By default, the local port is bound in accordance with the GatewayPorts setting.
However, an explicit bind_address may be used to bind the connection to a specific address.
The bind_address of “localhost” indicates that the listening port be bound for local use 
only, while an empty address or ‘*’ indicates that the port should be available from 
all interfaces.

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.