Hass docker and mqtt

Hi,

i try to get mqtt working. After adding mqtt: to my config it shows up in hass but not working with the other one i created on a different server. I added the main machine ip as broker (same network atm) but no luck. Then i tried to use an external service (cloudmqtt). Here i was not able to start hass without config error, no idea what the problem was i looked like shown in hass config sample. So i started trying the console mosquito commands. Here i only get “error connection refused”. host, port, user and pass (created and added read and write access) and topic are ok. So i have no more idea what to check, maybe my docker machine is the problem but i have no idea what to do.

So conclusion
Home Assistant 51.2 in docker container

The tested terminal commands
mosquitto_pub -h m20.cloudmqtt.com -p 23844 -t home-assistant/switch/1/on -u username -P password -m "Switch is ON"

mosquitto_pub -h m20.cloudmqtt.com -p 13844 -t home-assistant/switch/1/on -u username -P password -m "Switch is ON"

The Hass mqtt configuration

mqtt:
  broker: m20.cloudmqtt.com
  port: 13844
  username: !secret mqtt_user
  password: !secret mqtt_pass

I hope someone here has an idea and can help, thanks.