Skip to content

Instantly share code, notes, and snippets.

@Sal7one
Last active May 17, 2026 02:50
Show Gist options
  • Select an option

  • Save Sal7one/01ba13efe0cf49ee391d9075ba3985dd to your computer and use it in GitHub Desktop.

Select an option

Save Sal7one/01ba13efe0cf49ee391d9075ba3985dd to your computer and use it in GitHub Desktop.
MacOS Screen Sharing not working locally even though things look good Fix

Debugging macOS Screen Sharing When Bonjour Works but IPv4 Fails

I had a weird macOS homelab issue where Screen Sharing stopped working. At first it looked like the remote Mac was broken, but the real problem was much lower in the network stack: stale or broken IPv4 ARP/neighbor state.

This write-up explains the debugging path and the lesson.

TLDR: clearing ARP fixed the issue. OR USE direct IPV6 Instead of IPV4 192.xx

in terminal and go nuts! e.g.

open 'vnc://[2111:12C2:1111:1220:1459:7802:44FE:5554]'

Symptoms

From my client Mac, the remote Mac was visible through Bonjour/mDNS:

dns-sd -B _rfb._tcp local.
dns-sd -B _ssh._tcp local.

The remote machine advertised both:

_rfb._tcp   # Screen Sharing / VNC
_ssh._tcp   # SSH

Resolving the service also worked:

dns-sd -L "Remote Mac" _rfb._tcp local.
dns-sd -L "Remote Mac" _ssh._tcp local.

Example output:

Remote Mac._rfb._tcp.local. can be reached at remote-host.local.:5900
Remote Mac._ssh._tcp.local. can be reached at remote-host.local.:22

So discovery was working.

But direct IPv4 access failed:

ping -c 3 192.168.1.50
nc -4 -G 3 -vz remote-host.local 22
nc -4 -G 3 -vz remote-host.local 5900

The result was timeout / no response.

However, IPv6 worked:

nc -6 -G 3 -vz remote-host.local 22
nc -6 -G 3 -vz remote-host.local 5900

Both SSH and Screen Sharing ports were reachable over IPv6.

Forcing Screen Sharing to use the IPv6 address worked:

open 'vnc://[2001:db8::1234]'

But using the hostname or IPv4 address failed:

open "vnc://remote-host.local"
open "vnc://192.168.1.50"

The Key Realization

This was not actually a Screen Sharing problem.

It was not SSH.

It was not Bonjour.

It was not the macOS firewall.

It was an IPv4 path problem.

The remote Mac was alive and services were running, because IPv6 could reach them. Only IPv4 was broken.

The situation looked like this:

IPv4:
Client Mac -> 192.168.1.50 -> timeout

IPv6:
Client Mac -> 2001:db8::1234 -> works

That means the service was healthy, but IPv4 delivery on the LAN was broken.


Why Bonjour Still Worked

Bonjour/mDNS can show that a service exists:

"remote-host.local offers SSH"
"remote-host.local offers Screen Sharing"

But service discovery is not the same as reachability.

A useful rule:

Seeing a service is not proof that you can reach the service.

The network stack still has to resolve and deliver packets correctly.


The Mental Model

When connecting to a local Mac, the flow looks like this:

Hostname
  ↓
IP address: IPv4 or IPv6
  ↓
TCP port: 22 for SSH, 5900 for Screen Sharing
  ↓
Layer 2 neighbor mapping
  ↓
Wi-Fi / Ethernet

In my case:

Hostname resolution: worked
Bonjour discovery: worked
SSH service: worked
Screen Sharing service: worked
IPv6: worked
IPv4: failed

So the failure was lower than the application layer.


IPv4 vs IPv6 Neighbor Discovery

IPv4 on a LAN uses ARP.

Before a machine can send traffic to:

192.168.1.50

it needs to know the target device’s MAC address.

So it asks:

Who has 192.168.1.50?

That is ARP.

IPv6 does not use ARP. It uses Neighbor Discovery Protocol, or NDP.

So it is possible for IPv4 to be broken while IPv6 still works.

That is exactly what happened here.


The Debugging Steps

1. Check local network

On the client Mac:

ifconfig en0 | egrep "inet |inet6 |status:"
route -n get default

Confirm that both machines are on the expected LAN.

Example:

Client: 192.168.1.20
Remote: 192.168.1.50
Gateway: 192.168.1.1

2. Check Bonjour discovery

dns-sd -B _rfb._tcp local.
dns-sd -B _ssh._tcp local.

If the remote Mac appears here, discovery is working.


3. Resolve the advertised hostname

dns-sd -L "Remote Mac" _rfb._tcp local.
dns-sd -L "Remote Mac" _ssh._tcp local.

Then resolve the hostname:

dns-sd -G v4v6 remote-host.local

You may see both IPv4 and IPv6 addresses.


4. Test IPv4 and IPv6 separately

echo "IPv4 SSH:"
nc -4 -G 3 -vz remote-host.local 22

echo "IPv6 SSH:"
nc -6 -G 3 -vz remote-host.local 22

echo "IPv4 Screen Sharing:"
nc -4 -G 3 -vz remote-host.local 5900

echo "IPv6 Screen Sharing:"
nc -6 -G 3 -vz remote-host.local 5900

If IPv4 fails but IPv6 succeeds, the remote service is probably fine.

The problem is IPv4-specific.


5. Check firewalls

On both Macs:

sudo pfctl -s info
sudo pfctl -sr | head -120

Also check the macOS Application Firewall:

sudo /usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --getblockall
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --getstealthmode

In my case, both pf and the Application Firewall were disabled, so the firewall was not the cause.


6. Check ARP

On the client Mac:

arp -an | grep 192.168.1.50

On the remote Mac:

arp -an | grep 192.168.1.20

If ARP state is stale or weird, clear it.

On the client:

sudo arp -d 192.168.1.50

On the remote Mac:

sudo arp -d 192.168.1.20

Or clear all ARP entries:

sudo arp -d -a

Then retest:

ping -c 3 192.168.1.50
nc -4 -G 3 -vz 192.168.1.50 22
nc -4 -G 3 -vz 192.168.1.50 5900

In my case, clearing ARP fixed the issue.


Why "No Route to Host" Can Be Misleading

One of the confusing errors was:

ping: sendto: No route to host

That sounds like a routing problem.

But on a local subnet, it can also mean the machine cannot resolve or reach the Layer 2 neighbor.

In plain English:

I know the IP should be local, but I cannot deliver packets to the device behind that IP.

So do not immediately assume the router or default gateway is the problem.

It may be stale ARP or broken neighbor state.


Quick Fix Commands

Assume:

Client Mac: 192.168.1.20
Remote Mac: 192.168.1.50

On the client Mac:

sudo arp -d 192.168.1.50

On the remote Mac:

sudo arp -d 192.168.1.20

Then retest from the client:

ping -c 3 192.168.1.50
nc -4 -G 3 -vz 192.168.1.50 22
nc -4 -G 3 -vz 192.168.1.50 5900
open "vnc://192.168.1.50"

Temporary IPv6 Workaround

If IPv4 is broken but IPv6 works, you can force Screen Sharing to use IPv6:

open 'vnc://[2001:db8::1234]'

For link-local IPv6 addresses, include the interface scope.

Example:

open 'vnc://[fe80::1234:5678:abcd:ef12%25en0]'

The %25en0 part is important because % must be URL-escaped inside a URL.


Long-Term Prevention

Use a DHCP reservation on the router instead of manually hardcoding IPs on devices.

Recommended setup:

Remote Mac network setting: DHCP
Router: reserves a fixed IP for the remote Mac

Example:

Device: Remote Mac
Reserved IP: 192.168.1.50

Avoid having multiple devices manually configured with overlapping static IPs.

If LAN access becomes weird again, clear ARP on both sides:

sudo arp -d -a

Then reconnect.

macos screen-sharing vnc ssh bonjour mdns dns-sd ipv4 ipv6 arp neighbor-discovery network-debugging homelab lan troubleshooting macOS Screen Sharing Bonjour works but cannot connect macOS Screen Sharing IPv6 works IPv4 fails macOS VNC IPv6 works IPv4 timeout macOS remote login SSH IPv6 works IPv4 fails macOS SalehHomelab.local resolves but ping IPv4 timeout macOS .local hostname resolves to IPv6 but IPv4 fails macOS nc -6 works nc -4 timeout macOS Screen Sharing port 5900 open but unable to communicate macOS Screen Sharing "Unable to communicate" firewall not blocking macOS ARP stale Screen Sharing not working macOS ARP cache issue IPv4 timeout macOS clear ARP cache fixes SSH macOS clear ARP cache fixes VNC macOS "No route to host" same subnet ARP macOS ping sendto No route to host local network macOS Bonjour service discovered but connection timeout macOS mDNS works but IPv4 connection fails macOS dns-sd _rfb._tcp works but VNC fails macOS dns-sd _ssh._tcp works but SSH fails macOS local network IPv4 broken IPv6 works macOS IPv4 neighbor cache stale macOS ARP neighbor state broken macOS VNC 5900 timeout IPv4 only macOS SSH 22 timeout IPv4 only macOS remote management IPv6 only works macOS Screen Sharing force IPv6 address macOS VNC IPv6 literal works hostname fails macOS hostname chooses IPv4 first VNC fails macOS ARP delete fixes local network macOS arp -d fixes connection timeout macOS stale ARP no route to host macOS local subnet no route to host ARP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment