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
sudo ss -ltnp 'sport = :5222'
sudo lsof -nP -iTCP:5222 -sTCP:LISTEN
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:
sudo kill $(sudo lsof -t -iTCP:5222 -sTCP:LISTEN)
Stop-Process -Id (Get-NetTCPConnection -LocalPort 5222 -State Listen).OwningProcess
Open port 5222 in the firewall
sudo ufw allow 5222/tcp
# Close it again:
sudo ufw delete allow 5222/tcp
sudo firewall-cmd --permanent --add-port=5222/tcp
sudo firewall-cmd --reload
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
nc -zv example.com 5222
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.