It turned out it was a wrong default home dir for the ejabberd user and the ejabberdctl script uses the ejabberd user.
[root@server2 ~]# getent passwd ejabberd
ejabberd:x:1000:1000::/opt/ejabberd-16.01:/bin/bash
After changing the homedir it just worked without errors.
usermod -d /opt/ejabberd ejabberd
I think it’s from an old update or ejabberd testing.
I found similar error here.