DevToolsmith

Port 5222: XMPP client

Port 5222 (TCP) is used by XMPP (Jabber) clients to connect to chat servers. It is a registered port (1024–49151), so any user can listen on it.

Service
XMPP client
Protocol
TCP
Range
Registered (1024–49151)
Official
IANA-registered
Exposure
Meant to be public
Category
Messaging and queues

What uses port 5222

XMPP is an open chat protocol behind servers like Prosody and ejabberd and clients like Conversations and Gajim. Clients connect on 5222 with STARTTLS; servers federate with each other on 5269. WhatsApp was originally built on a modified XMPP.

Should port 5222 be open to the internet?

Meant to be public. This port is meant to be reachable by clients on the internet when you run this service publicly.

Check what is listening on port 5222

Linux
sudo ss -ltnp 'sport = :5222'
macOS
sudo lsof -nP -iTCP:5222 -sTCP:LISTEN
Windows (PowerShell)
Get-NetTCPConnection -LocalPort 5222 -State Listen
netstat -ano | findstr :5222

No output means nothing is listening. If a service should be, check that it is running and which address it binds to: 127.0.0.1 only accepts local connections, 0.0.0.0 or :: accepts them on every interface.

Fix “address already in use” on port 5222

Another process already holds the port. Find it with the commands above, then stop that service properly, or end the process:

macOS / Linux
sudo kill $(sudo lsof -t -iTCP:5222 -sTCP:LISTEN)
Windows (PowerShell)
Stop-Process -Id (Get-NetTCPConnection -LocalPort 5222 -State Listen).OwningProcess

Open port 5222 in the firewall

Ubuntu / Debian (ufw)
sudo ufw allow 5222/tcp
# Close it again:
sudo ufw delete allow 5222/tcp
RHEL / Fedora / Rocky (firewalld)
sudo firewall-cmd --permanent --add-port=5222/tcp
sudo firewall-cmd --reload
Windows (PowerShell, as administrator)
New-NetFirewallRule -DisplayName "XMPP client 5222/TCP" -Direction Inbound -Protocol TCP -LocalPort 5222 -Action Allow

On AWS, Google Cloud and Azure, also allow the port in the security group or network firewall rules; host firewalls and cloud firewalls are separate.

Test port 5222 from another machine

macOS / Linux
nc -zv example.com 5222
Windows (PowerShell)
Test-NetConnection example.com -Port 5222

Related ports

  • Port 443 (HTTPS): the default port for HTTPS, encrypted web traffic.

More messaging and queues ports

1883 (MQTT) , 4222 (NATS) , 4369 (Erlang Port Mapper (epmd)) , 5060 (SIP) , 5672 (AMQP (RabbitMQ)) , 8883 (MQTT over TLS) , 9092 (Apache Kafka) , 15672 (RabbitMQ management) . See all ports in the port lookup.

Sources

Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.

Frequently asked questions

What is port 5222 used for?

Port 5222 is used by XMPP (Jabber) clients to connect to chat servers. XMPP is an open chat protocol behind servers like Prosody and ejabberd and clients like Conversations and Gajim. Clients connect on 5222 with STARTTLS; servers federate with each other on 5269. WhatsApp was originally built on a modified XMPP.

Is it safe to open port 5222?

This port is meant to be reachable by clients on the internet when you run this service publicly. Keep the service behind it up to date and require authentication where it applies.

How do I check if port 5222 is open?

On the server, list listening sockets with "sudo ss -ltnp 'sport = :5222'" on Linux or "sudo lsof -nP -i :5222" on macOS. From another machine, run "nc -zv host 5222" or, on Windows, "Test-NetConnection host -Port 5222". Connection refused means nothing is listening; a timeout means a firewall is dropping the traffic.