Ugh. I found the problem.
I was replacing ejabberd with Openfire on this server, and ejabberd was still installed.
I discovered the problem by running netstat -nlp |grep java
and found this:
root@worker2:/etc/openfire/security# netstat -nlp |grep java
tcp6 0 0 :::9090 :::* LISTEN 32359/java
tcp6 0 0 :::9091 :::* LISTEN 32359/java
tcp6 0 0 :::5229 :::* LISTEN 32359/java
tcp6 0 0 :::5262 :::* LISTEN 32359/java
tcp6 0 0 :::5263 :::* LISTEN 32359/java
tcp6 0 0 :::7443 :::* LISTEN 32359/java
tcp6 0 0 :::5276 :::* LISTEN 32359/java
tcp6 0 0 :::7070 :::* LISTEN 32359/java
Wait, no port 5222 or 5223?
root@worker2:/etc/openfire/security# netstat -nlp |grep 5222
tcp 0 0 0.0.0.0:5222 0.0.0.0:* LISTEN 3153/beam
So because port 5222 was already in use, Openfire couldn’t start the server on that port. I removed ejabberd and restarted Openfire, and now I’m connecting to the right server.
It also helps to search /var/log/openfire/all.log for the string “ERROR”, although it doesn’t exactly say that the socket is already in use.