I have a PI 4 with ethernet connection and I am unable to connect to the pi from any external connections (SSH, VNC, or Nginx). All external connection results in connection refused but I can access these services just fine within the Pi.

I did a nmap scan on which returned this:

Starting Nmap 7.92 ( https://nmap.org ) at 2021-12-02 22:28 EST
Nmap scan report for dhcp-234-248.resnet.purdue.edu (
Host is up (0.033s latency).
Not shown: 96 closed tcp ports (reset)
22/tcp   open     ssh
25/tcp   filtered smtp
80/tcp   open     http
5900/tcp open     vnc

Nmap done: 1 IP address (1 host up) scanned in 1.48 seconds

So IP address is accessible but I can't access the services?

Also, there are no iptables or ufw installed.

Anyone know what could be causing this? Thanks.

  • is the IP address of the Pi? Unusual for a pi to be directly connected to the internet like that, but, who knows with .edu
    – Bravo
    Dec 3, 2021 at 4:39
  • Yes, it is, our school's internet is weird. All devices connected by the ethernet are automatically exposed to the internet, with all the ports forwarded with their own unique IP address (I think).
    – sqz
    Dec 3, 2021 at 5:25
  • (I think) - important that you know for sure - seems like you may be wrong :p but, ip a on the pi shows that address?
    – Bravo
    Dec 3, 2021 at 5:54
  • Yes it indeed shows the same IP address
    – sqz
    Dec 3, 2021 at 14:53
  • Also, Connecting the ethernet cable to my laptop allow RDP connections from the internet.
    – sqz
    Dec 3, 2021 at 15:13

1 Answer 1


Ok, I figured it out. As it turns out, when I installed Docker on my machine, it automatically added the following records to the host file.

# Added by Docker Desktop host.docker.internal gateway.docker.internal
# To allow the same kube context to work on the host and the container: kubernetes.docker.internal
# End of section

and when I tried to ssh into the Pi via IP, ssh will resolve to host.docker.internal, resulting in a connection refused error. Removing these records from hosts file allowed me to connect to the PI.

The reason why that issue did not show up during nmap is that I had to use my cloud-hosted server to run the scan which has a perfectly fine hosts file.

  • I am not sure if this is a docker's feature or not. If not, should I file a bug report to docker?
    – sqz
    Dec 3, 2021 at 21:27
  • does "on my machine" refer to the pi?
    – Bravo
    Dec 3, 2021 at 22:32
  • It’s referring to my laptop which I was trying to connect to the PI from.
    – sqz
    Dec 3, 2021 at 23:44
  • 1
    so, it was an issue on the laptop, not on the raspberry pi
    – Bravo
    Dec 4, 2021 at 0:48
  • 1
    Yes. The docker installation on the laptop lead to incorrect resolution of PI’s IP address.
    – sqz
    Dec 4, 2021 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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