Skip to content
statance
MenuClose
← All ports

Port 5900: VNC

High risk

Port 5900 is VNC remote desktop. Display :1 uses 5901, display :2 uses 5902 and so on. It should not be reachable from the public internet.

Port
5900
Protocol
TCP
Service
VNC
Expose to internet?
No
Also used by
TightVNC, TigerVNC, RealVNC, macOS Screen Sharing, QEMU/KVM consoles

Is port 5900 safe to open?

Classic VNC authentication uses a password limited to eight characters and the session is unencrypted. Exposed VNC servers, some with no password at all, have shown screens of industrial controls, medical systems and home computers. Treat it like RDP: never directly on the internet.

How to secure VNC

  • Bind VNC to localhost and connect through an SSH tunnel: ssh -L 5901:localhost:5901 user@host.
  • Or put it behind a VPN.
  • Always set a password, and prefer servers that support encrypted sessions.
  • For hypervisor consoles, keep VNC on the management network only.

Check if port 5900 is open

Linux: what is listening on this port

sudo ss -tlpn | grep ':5900 '

Windows (PowerShell): what is listening

Get-NetTCPConnection -LocalPort 5900 -State Listen | Select-Object LocalAddress, OwningProcess, @{n='Process';e={(Get-Process -Id $_.OwningProcess).Name}}

From another machine: is it reachable

nc -zv HOST 5900 # or nmap -p 5900 HOST # Windows Test-NetConnection HOST -Port 5900

Test the VNC service itself

nc -vz HOST 5900

Restrict port 5900 in the firewall

Replace 10.0.0.0/8 with the network or address that needs access. Docker publishes container ports through its own iptables rules, which bypass ufw; bind published ports to 127.0.0.1 (-p 127.0.0.1:5900:5900) instead of relying on the host firewall.

ufw: allow only your private network, deny everyone else

sudo ufw allow from 10.0.0.0/8 to any port 5900 proto tcp sudo ufw deny 5900/tcp

firewalld: allow one source network only

sudo firewall-cmd --permanent --remove-port=5900/tcp sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.0.0/8" port port="5900" protocol="tcp" accept' sudo firewall-cmd --reload

iptables

sudo iptables -A INPUT -p tcp --dport 5900 -s 10.0.0.0/8 -j ACCEPT sudo iptables -A INPUT -p tcp --dport 5900 -j DROP

Windows Firewall (PowerShell, as Administrator)

New-NetFirewallRule -DisplayName "Block 5900 from internet" -Direction Inbound -Protocol TCP -LocalPort 5900 -RemoteAddress Internet -Action Block

Monitor port 5900

Run a TCP port monitor against your public IP on port 5900: here, a failed connection is the healthy result, so you know the firewall is still doing its job. On Linux, the Statance agent also reports every listening port on the server. TCP port monitoring.

Related ports

Port 3389Remote Desktop (RDP)High risk
Port 22SSHMedium risk
Port 6000X11High risk

FAQ

What is port 5900 used for?

Port 5900 is VNC remote desktop. Display :1 uses 5901, display :2 uses 5902 and so on. It is also used by TightVNC, TigerVNC, RealVNC, macOS Screen Sharing, QEMU/KVM consoles.

Is it safe to open port 5900?

Not to the public internet. Classic VNC authentication uses a password limited to eight characters and the session is unencrypted. Exposed VNC servers, some with no password at all, have shown screens of industrial controls, medical systems and home computers. Treat it like RDP: never directly on the internet.

Is port 5900 TCP or UDP?

VNC uses TCP on port 5900.

How do I check if port 5900 is open?

On the server, run sudo ss -tulpn | grep ':5900 ' (Linux) or Get-NetTCPConnection -LocalPort 5900 (Windows) to see what is listening. From another machine, run nc -zv HOST 5900 or Test-NetConnection HOST -Port 5900.

All ports →

Know the moment a port stops answering.

TCP, HTTP, DNS and SSL checks from six regions, plus server metrics from a one-line agent.