Port 502: Modbus TCP

Port 502 (TCP) is used by Modbus TCP. Industrial control protocol for PLCs and inverters. No authentication; keep it on isolated networks.

502Port
TCPProtocol
mbapIANA service name
IoT & industrialCategory

Port range

502 is a well-known (system) port (range 0–1023). On Linux and macOS, binding to it traditionally needs root or the CAP_NET_BIND_SERVICE capability.

Security

Port 502 should not be reachable from the public internet. Restrict it to trusted networks or a VPN, and scan your public IP to confirm it is closed.

Open port 502 in a firewall

ufw         sudo ufw allow 502/tcp
iptables    sudo iptables -A INPUT -p tcp --dport 502 -j ACCEPT
firewalld   sudo firewall-cmd --permanent --add-port=502/tcp
Windows     New-NetFirewallRule -DisplayName "Modbus TCP 502" -Direction Inbound -Protocol TCP -LocalPort 502 -Action Allow

Check if port 502 is open

nc -vz example.com 502
Test-NetConnection example.com -Port 502   # PowerShell
sudo ss -tulpn | grep ':502 '   # what is listening locally (Linux)

Other iot & industrial ports

Frequently asked questions

What is port 502 used for?
Modbus TCP. Industrial control protocol for PLCs and inverters. No authentication; keep it on isolated networks.
Is port 502 TCP or UDP?
TCP.