OpenHab3 with influxdb 2.1 persistence: "unauthorized access"

Setting up a brand new machine with the latest of everything.

  • Platform information:
    • OS: debian 11
    • Java Runtime Environment: OpenJDK Runtime Environment Zulu11.54+25-CA
    • openHAB version: 3.2.0
    • influxdb v2.1

Persistence is failing to connect to Influxdb

influxdb configuration is (I have trimmed the token):

# influx org list | grep shade
d2e8dc0d3b22984d	shade
# influx bucket list | grep enviro
ba66688e63b1cec8	enviro		infinite	168h0m0s		d2e8dc0d3b22984d	implicit
influx auth list | grep openhab3
ID			Description	Token User Name	User ID	Permissions
08f8562e2093c000	openhab3	00...==	admin		08f74450b593c000	[read:orgs/d2e8dc0d3b22984d/buckets/ba66688e63b1cec8 write:orgs/d2e8dc0d3b22984d/buckets/ba66688e63b1cec8]

openhab3 user should be able to connect to enviro bucket, org shade, using the “00…==” read/write token

Following the instructions for Influxdb V2 at InfluxDB (0.9 and newer) - Persistence Services | openHAB, I configured the influxdb service

#cat /etc/openhab/services/influxdb.cfg 

# name of Organisation in InfluxDB V2
# name of Bucket in InfluxDB V2

Restart openhab3, configure persistence for some items, and the openhab.log shows:

2022-02-25 12:25:37.240 [ERROR] [] - The error occurred during writing of data
com.influxdb.exceptions.UnauthorizedException: unauthorized access
	at com.influxdb.internal.AbstractRestClient.responseToError( ~[bundleFile:?]
	at com.influxdb.client.internal.AbstractWriteClient.toInfluxException( ~[bundleFile:?]
	at com.influxdb.client.internal.AbstractWriteClient.lambda$new$12( ~[bundleFile:?]

I tried using the admin token with all permissions, with same error resulting.


bucket = "enviro"
client = InfluxDBClient(url="http://localhost:8086", token="00...==", org="shade")

in a test python script connected to influxdb and wrote successfully.

Hey @morrowwm did you find a solution, I have the same problem with openhab 3.3.0 and influx db 2.4

@ComJack85 I’ve recently upgraded and found that I could not use either a bucket or user that had a digit in the name, such as ‘openhab3’, as soon as I changed back to ‘openhab’ for bucket and username it started working. Confirmed broken if I add back in the digit in bucket by rename, and in config UI, it does not work.

@lordmorgul This is not the case for me, the bucket and name do not contain a digit. :melting_face:

@lordmorgul But it gave me an idea. Under Settings - InfluxDB Persistence Service, I entered the token and left the password field empty. Now it works.


I had a very similar problem with OH 3.4.0 and InfluxDB 2.6.1.

For me, the solution was to remove the double-quotes from the token definition in /etc/openhab/services/influxdb.cfg

So, instead of:

write just this:

Hope that helps someone else.

I wanted to try to leave the password empty, unfortunately it won’t update. I can change the password but if I leave it empty, the old password re-appears. Also tried to re-install the plugin but the settings persist.
Its exactly these thing why I prefer textual configuration !