Three things decide who can reach a VNC server: the address it listens on, the client addresses the server itself accepts, and whether your router maps a public port to it. To keep VNC on the local network only, bind the server to the machine's LAN address, let it (or the host firewall) admit only your subnet, make sure no port forward or UPnP mapping points at it, and then prove it with a probe from a second LAN machine and one from outside.
Check IPv6 while you're at it. On Debian 13, x11vnc bound to an IPv4 LAN address still opens a listener on [::], and a host with a global IPv6 address needs no router mapping to be reachable.
How the listener, the server's filter and the router fit together

A viewer reaches a VNC server when its packets get to the address and port the server listens on. Display :1 listens on TCP port 5901, display :2 on 5902, and so on. That gives you three places to close the door:
- The listener address. A server bound to
0.0.0.0or[::]answers on every interface the machine has, VPN and Docker bridges included. Bound to192.168.x.yit answers only on that interface; bound to loopback, only to the machine itself. - The server's own client filter. x11vnc and RealVNC Server can refuse clients by address. TigerVNC can't, so subnet filtering there belongs to the host firewall.
- The router. Your LAN uses private addresses that the internet doesn't route, so an outside host gets in only through a port forward, a mapping a LAN device requested over UPnP, or a global IPv6 address on the server.
The listener is the setting you control on the server, so start there.
See what the server listens on right now

On Linux, list the listening sockets and read the Local Address column:
sudo ss -ltnp | grep ':59'
0.0.0.0:5901 or [::]:5901 means every interface, and 127.0.0.1:5901 with [::1]:5901 means loopback only. A LAN-only server shows exactly one line, <lan-ip>:5901. The [::] line is the one people miss: it takes connections on any IPv6 address the host has. A wildcard bind is what a program gets when it passes INADDR_ANY to bind().
A stock tigervncserver :1 on Debian 13 or Ubuntu 26.04 already shows the loopback pair, because the wrapper listens on localhost only while its security types hold no TLS or X509 type. That's safe, but no LAN viewer can reach it. On a Mac use sudo lsof -iTCP:5900 -sTCP:LISTEN, and on Windows netstat -ano | findstr :5900.
Bind TigerVNC to the LAN address on Debian 13 and Ubuntu 26.04

Both releases ship TigerVNC 1.15 with the tigervncserver wrapper and the tigervncserver@ unit. Xtigervnc takes one address through -interface and listens on all interfaces when you don't give one. The wrapper has to be told to stop forcing localhost as well, so put two lines in ~/.config/tigervnc/config.pl for the user who runs the session:
$interface = "<lan-ip>";
$localhost = "no";
1;
Keep that order. Setting $interface clears the localhost choice, so with $localhost = "no" on the line above it, the wrapper falls back to its default and starts Xtigervnc with -interface <lan-ip> -localhost=1, which still listens on loopback only. With $localhost = "no" the wrapper also changes its default security types from VncAuth to VncAuth,TLSVnc.
To enforce the address for every user on the machine, put the same lines in /etc/tigervnc/vncserver-config-mandatory. tigervncsession reads /etc/tigervnc/vncserver-config-defaults, then the user's config.pl, then the mandatory file, so the mandatory file wins.
Restart the session so it binds the new address. On these releases systemctl restart leaves the old session's helper processes behind, so stop the unit, end the user's leftover processes, then start it. Run these from another account or the console, because terminate-user also ends that user's own logins:
sudo systemctl stop tigervncserver@:1
sudo loginctl terminate-user <user>
sudo systemctl start tigervncserver@:1
For a session you started by hand, run tigervncserver -kill :1 and then tigervncserver :1. Run the ss line again: you should see <lan-ip>:5901 and nothing else, with no [::] line, because Xtigervnc binds only the IPv4 address you named.
If the address isn't on the machine when the session starts, Xtigervnc exits at once and its log ends with vncExtInit: No path or port configured for incoming connections. A DHCP lease that changed does that, so give the server a reserved or static address before you bind to it.
TigerVNC has no allow-list of client addresses. Its only per-host control, UseBlacklist, blocks a host for a while after repeated failed logins. To admit just your subnet, add a host firewall rule for the port; the firewall rules page covers that.
Fedora and RHEL: what changes

Fedora and RHEL start sessions through the vncserver@ unit and upstream's vncsession, which don't force localhost, so Xvnc listens on every IPv4 and IPv6 address until you set one. The session log then carries Listening for VNC connections on all interface(s), port 5901. The config files use plain option=value lines instead of Perl, so the mandatory file takes one line:
interface=<lan-ip>
Then restart with sudo systemctl restart vncserver@:1 and check ss the same way.
Restrict x11vnc with -listen, -allow and the IPv6 listener

x11vnc shares an existing X display (an Xorg session, not a Wayland one), and by default it answers on every interface on port 5900. Three options close it down: -listen binds the IPv4 listener to one address, -allow refuses clients outside a list, and the IPv6 pair shuts the [::] listener. Start it from a terminal inside the desktop session (echo $DISPLAY there gives you the display number):
x11vnc -storepasswd
x11vnc -display :<display> -listen <lan-ip> -allow <lan-prefix> -noipv6 -rfbportv6 -1 -rfbauth ~/.vnc/passwd -forever
-allowtakes host names, addresses, or a numeric prefix ending in a dot, so for a /24,<lan-prefix>is its first three octets followed by the dot. A value containing/is read as a file of addresses and prefixes, re-read each time a client connects, so you can edit the list without a restart.- On Debian 13 and Ubuntu 26.04 (x11vnc 0.9.17),
-listen <lan-ip>still leaves a listener on[::]:5900, and-no6or-noipv6alone doesn't remove it. With-noipv6 -rfbportv6 -1together,ssshows only<lan-ip>:5900. x11vnc -storepasswdprompts for a password and writes~/.vnc/passwd, which-rfbauththen requires. Without-forever, x11vnc exits when the first viewer disconnects.
To make it the default for every start, put one option per line in ~/.x11vncrc. x11vnc passes ~ in that file through as a literal character, so give the password file's full path:
-listen <lan-ip>
-allow <lan-prefix>
-noipv6
-rfbportv6 -1
-rfbauth /home/<user>/.vnc/passwd
-forever
x11vnc -Q listen and x11vnc -Q allow ask the running server what it's using and answer ans=listen:<lan-ip> and ans=allow:<lan-prefix>.
RealVNC Server: listen addresses, client filter and cloud connections

RealVNC Server does both jobs in its own parameters. IpListenAddresses restricts direct connections to the addresses you list, and IpClientAddresses takes an ordered list of + (permit), - (reject) and ? (flag) entries, where a trailing - rejects everyone not matched earlier. Both need an Enterprise subscription. On Linux, Service Mode reads /etc/vnc/config.d/vncserver-x11, one Name=value per line:
IpListenAddresses=<lan-ip>
IpClientAddresses=+<lan-subnet>/24,-
AllowCloudRfb=FALSE
The third line matters for a LAN-only goal. IpClientAddresses filters direct connections only, and cloud connections pass it by, so turn them off if cloud connectivity is on. Apply the file to running servers with sudo vnclicense -reload, which reloads every running instance for all users.
macOS Screen Sharing: choose who, not where

Screen Sharing's settings pick who may connect; the LAN boundary on a Mac comes from the router and the firewall. Open Apple menu > System Settings > General > Sharing, click the Info button next to Screen Sharing, and under Allow access for choose Only these users. Controlling the screen gives nearly unrestricted access to the Mac, so keep that list short. Turn on "VNC viewers may control screen with password" only for third-party viewers, and give it a password no account on the Mac uses.
Remove router port forwards and UPnP mappings

A forward on the router that points at the VNC host undoes everything above, and so does a UPnP mapping some program on the LAN requested without asking. In the router's admin page, delete any forward to the VNC host's address or to a 5900-range port, and turn UPnP off unless something on the LAN needs it.
Then ask the router what it holds from any LAN machine with upnpc (package miniupnpc):
upnpc -l
Mappings print under the header i protocol exPort->inAddr:inPort description remoteHost leaseTime. No row should name the VNC host as inAddr. Delete a leftover by its external port and protocol:
upnpc -d <external-port> TCP
Prove it: a LAN probe, an outside probe and the hairpin trap

From a second machine on the LAN, check that the port answers:
nc -zv -w 3 <lan-ip> 5901
An open port prints Connection to <lan-ip> 5901 port [tcp/*] succeeded!. On Windows, Test-NetConnection <lan-ip> -Port 5901 runs the same check. A successful nc -z proves the listener is reachable, not that the allow-list let you in. x11vnc sends its RFB 003.008 greeting to every client and drops a host outside -allow right after the version exchange, so that host still gets "succeeded" from nc. To test the list, point a real viewer at the server from a machine outside it: the connection closes before any password prompt.
Now probe from outside the LAN: a phone hotspot with the laptop's Wi-Fi off the LAN works. Use the router's public address:
nc -zv -w 5 <public-ip> 5901
A timeout or Connection refused is the result you want. Don't run this one from inside the LAN. Many routers loop traffic aimed at their own public address back to the internal host (hairpinning), so an inside test can succeed or fail for reasons that say nothing about outside reach.
Last, IPv6. List the host's global addresses:
ip -6 addr show scope global
If that prints an address and ss shows a [::] listener, probe that address from outside too with nc -6 -zv -w 5 <global-ipv6> 5901. Whether it answers depends on the router's IPv6 firewall, not on any port forward.
What a LAN boundary still lets in

Binding to the LAN stops the internet, not your neighbours on the network. Every device on that subnet can reach the listener, including a laptop someone brought in, a compromised IoT box, and any VPN client the router places on the LAN. A cloud or relay service the server dials out to also skips the boundary, which is why the RealVNC section turns cloud connections off.
So keep a password on every LAN listener. Plain RFB has no protection against observation or tampering beyond the optional VNC password check, so anyone who can sniff the LAN segment can watch a session in the clear. Restricting the port to your subnet at the host firewall is covered on the firewall configuration page, and a wider audit of what a host exposes to the internet is on the internet exposure audit page.
Reach a LAN-only server from outside through SSH

Keep VNC off the router and tunnel it over SSH. That trades an open VNC port for an SSH server that has to be reachable from outside, through a forward of its own or a VPN into the LAN, so lock SSH down with keys before you open it.
From the viewer machine, forward a local port to the VNC listener on the server. Point the far end at the address the server actually listens on: after binding TigerVNC to <lan-ip>, nothing answers on the server's 127.0.0.1, so localhost there gets Connection refused.
ssh -N -L localhost:5901:<lan-ip>:5901 <user>@<server-host>
-N runs no remote command and holds the terminal while the tunnel is up, and the localhost bind address keeps the forwarded port for your machine alone. For a server left on Debian's loopback default, use localhost:5901 as the far end instead. Then, from a second terminal, connect the viewer to the near end. The double colon tells TigerVNC's viewer that 5901 is a port, not a display:
vncviewer localhost::5901
For remote access from outside, tunnel through SSH or a VPN and leave the VNC port unmapped. Bind the listener today, then run the outside probe from a phone hotspot. If it ever succeeds, look at the router before you look at the server.
FAQs
Can I drop the VNC password if the server is LAN only?
The Debian and Ubuntu tigervncserver wrapper won't let you on a LAN listener. Start it with -localhost no and -SecurityTypes None and it refuses with YOU ARE TRYING TO EXPOSE A VNC SERVER WITHOUT ANY AUTHENTICATION TO THE WHOLE INTERNET! unless you add --I-KNOW-THIS-IS-INSECURE. The wrapper is right: every device on the subnet could take the desktop.
Why does the VNC service fail at boot after I bound it to the LAN address?
Debian's tigervncserver@.service orders itself only After=network.target, which marks the network stack as started, not an address as assigned. If DHCP hasn't finished, the address doesn't exist yet and Xtigervnc exits. Make the unit wait for network-online.target with a drop-in:
sudo systemctl edit tigervncserver@.service
[Unit]
Wants=network-online.target
After=network-online.target
That only helps when the machine's network manager provides a wait-online service, which NetworkManager and systemd-networkd both do.
Discuss this in the community
Questions about this, or a setup it does not cover? Ask in Security and Remote Access.
Security and Remote Access group