InfluxDB OSS error with RuuviBridge

Hello, I have set up a Raspberry Pi 5 as a Ruuvi Bridge and it is working perfectly when I use as sink my cloud InfluxDB instance (InfluxDB Cloud Serverless - Storage Engine Version 3).
Now I am trying to set up a local InfluxDB instance (version 2.7.10) as sink and I’m getting the following error message:

[error] Failed to send data to InfluxDB, error: Post “http://localhost:8086/api/v2/write?bucket=mybucket&org=org&precision=ns”: dial tcp [::1]:8086: connect: connection refused

I am also periodically running some other scripts that successfully send their measurements on my local influxDB instance using the following command:

curl -i -XPOST “http://localhost:8086/api/v2/write?org=$INFLUX_ORG&bucket=$INFLUX_BUCKET&precision=s”
–header “Authorization: Token $INFLUX_TOKEN”
–header “Content-Type: text/plain; charset=utf-8”
–data-binary “$DATA”

Here’s the content of the RuuviBridge config.yml for the configuration of the influxdb sink in both scenarios:

InfluxDB Cloud - OK

influxdb_publisher:
enabled: true
minimum_interval: 1m
url: https://eu-central-1-1.aws.cloud2.influxdata.com
auth_token: “MY_CLOUD_TOKEN”
org: “org”
bucket: ruuvi
measurement: ruuvi_measurements

InfluxDB OSS - NOT working

influxdb_publisher:
enabled: true
minimum_interval: 1m
url: http://localhost:8086
auth_token: “MY_LOCAL_TOKEN”
org: “org”
bucket: ruuvi
measurement: ruuvi_measurements

The org name is correct, the bucket is set up correctly.

What might be the cause of this behavior? How can I fix?
Thank you for your help, I’m clearly missing something here but I haven’t been able to figure it out yet.

Hi @Sephiroth , thanks for your message!
I think @Scrin could possibly help you out with this.

dial tcp [::1]:8086: connect: connection refused means the other end refused the connection when attempting to port 8086 on localhost over IPv6. As curl seems to work fine, it might be that your InfluxDB is listening only on IPv4, in which case you could try:

url: http://127.0.0.1:8086

instead of

url: http://localhost:8086

to force RuuviBridge to use IPv4 instead. If that doesn’t work, could you test your curl script with the -v verbose flag to see where and how it actually connects to troubleshoot further?

1 Like

Thank you a lot for your quick answers!
Sadly, even with the explicit IPv4 url the result remains the same:

[error] Failed to send data to InfluxDB, error: Post “http://127.0.0.1:8086/api/v2/write?bucket=mybucket&org=org&precision=ns”: dial tcp 127.0.0.1:8086: connect: connection refused

With the verbose flag, this is the curl output:

* Trying 127.0.0.1:8086…
* Connected to localhost (127.0.0.1) port 8086 (#0)
> POST /api/v2/write?org=org&bucket=mybucket&precision=s HTTP/1.1
> Host: localhost:8086
> User-Agent: curl/7.88.1
> Accept: */*
> Authorization: Token *mytoken*
> Content-Type: text/plain; charset=utf-8
> Content-Length: 137
>
< HTTP/1.1 204 No Content
HTTP/1.1 204 No Content
< X-Influxdb-Build: OSS
X-Influxdb-Build: OSS
< X-Influxdb-Version: v2.7.10
X-Influxdb-Version: v2.7.10
< Date: Wed, 16 Oct 2024 06:18:03 GMT
Date: Wed, 16 Oct 2024 06:18:03 GMT

<
* Connection #0 to host localhost left intact

It just occurred me, are you running RuuviBridge in a docker container? In that case localhost is wrong, as it will point to the localhost of the container, not the “localhost” of the host machine, in which case you need to use a different address that properly points to your influxdb

Thank you for following up on this!

That is indeed the case, I was not aware that docker containers by default map localhost to the container itself and not to the host - with the correct mapping I could quickly verify that it works.

To solve the issue, either exchange localhost with 172.17.0.1 or follow the instructions on this StackOverflow post:
nginx - From inside of a Docker container, how do I connect to the localhost of the machine? - Stack Overflow

In the meantime I switched to a different solution, but hopefully this will be helpful in case someone is experiencing the same issue :slight_smile: