MQTT up and running on Pine 64 but opanHAB Not authorized to connect

I installed the pine64 image of openHAB and started the mosquitto option through the openhab-config. Works like a charm.

I can connect to mosquitto on the Pine using MQTT.fx (publish and subscribe) from my iMac.
I can connect openHab on the Pine with another mosquitto running on my iMac.
However openHAB on the Pine cannot connect to mosquitto on the Pine.

My config is:

mqtt:mqttbroker.url=tcp://openhabianpine64:1883
mqtt:mqttbroker.clientId=openhabian
openhabian.user=openhabian
openhabian.pwd=****

In the openhab.log the error is:

2017-09-02 23:59:32.134 [ERROR] [penhab.io.transport.mqtt.MqttService] - Error starting broker connection
Not authorized to connect (5)
	at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:28)[189:org.openhab.io.transport.mqtt:1.10.0]
	at org.eclipse.paho.client.mqttv3.internal.ClientState.notifyReceivedAck(ClientState.java:990)[189:org.openhab.io.transport.mqtt:1.10.0]
	at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:118)[189:org.openhab.io.transport.mqtt:1.10.0]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]

I have been looking at suggestions for 2 days, to no avail. Any suggestions?

The first thing to do is post all relevant config information. In this case, your mqtt.cfg. also relevant is whether oh and the broker are on the same machine.

Thanks, I have improved the OP

Make sure you have the username and password right.

Make sure you don’t have more than one client connected with the client id openhabian.

Make sure that mosquito is configured to listen on localhost or change the broker url in mqtt.cfg to use the Pine’s IP rather than hostname.

I solved it. Al credentials were right, but the reference in the config was wrong.

I used

mqtt:mqttbroker.url=tcp://openhabianpine64:1883
mqtt:mqttbroker.clientId=openhabian
openhabian.user=openhabian

It should be

mqtt:mqttbroker.url=tcp://openhabianpine64:1883
mqtt:mqttbroker.clientId=openhabian
mqtt:mqttbroker.user=openhabian

etc.