I have a Debian device on my local network (Raspberry Pi, but that's not important) and I wish to SSH from a Windows PC. When I try to connect to it using the local IP, everything works fine. But I wish to connect to it from outside also, so I setup a Dynamic DNS, port forward and I turned off router firewall. SSH is up and running, since I can access it locally and openssh-server is already installed.

When I try to connect using the global IP, I get a "Connection refused" error.

Why I can't connect from outside?

  • By local IP, I assume you mean localhost ( – Julian Knight Jan 20 '13 at 15:42

You can connect from the outside. You just can't connect from the inside using the outside IP address because port forwarding only works on connections from the outside. If you want to connect from inside machines to your outside IP address, you need hairpin NAT (sometimes also called 'loopback NAT') which is a form of dual NAT. Port forwarding won't do it.

I explain why this won't work in detail in this answer.

|improve this answer|||||

Does Debian on the Pi install IPTABLES by default? If so, this is because the IPTABLES firewall has not been configured to allow incoming SSH connections.

|improve this answer|||||

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.