InfluxDB integration: Cannot connect to remote InfluxDB: [Errno 111] Connection refused

Hi,

I’m trying to configure HA to read data from a remote InfluxDB 2.xx server (on the same LAN) in order to set HA sensor states/values. I do not want to write any HA entity data to InfluxDB.

My problem is that HA cannot establish a connection with the InfluxDB server. The HA log has entries like this:

023-07-09 10:18:53.122 ERROR (SyncWorker_8) [homeassistant.components.influxdb] Cannot connect to InfluxDB due to '<urllib3.connection.HTTPConnection object at 0x7f8b098b10>: Failed to establish a new connection: [Errno 111] Connection refused'. Please check that the provided connection details (host, port, etc.) are correct and that your InfluxDB server is running and accessible. Retrying in 60 seconds.

I have checked the host, port, organisation id, token values carefully. I can connect remotely to the InfluxDB server using the same values from the InfluxCLI tool. If I knew how to install an InfluxCLI tool on the HA RPi, I would try that…

Setup details:

  • Home Assistant 2023.7.1 using the HassOS image running on a RPi4 (OS: 10.3).
  • InfluxDB OSS version 2.7.1.

My configuration.yaml file includes the following:

influxdb:
  api_version: 2
  host: 192.168.2.2
  ssl: false
  organization: a175c98ba00784f7
  token: ThL80NgQ...==
  exclude:
    entity_globs: "*"

sensor:
  - platform: influxdb
    api_version: 2
    host: 192.168.2.2
    ssl: false
    organization: a175c98ba00784f7
    token: ThL80NgQ...==
    queries_flux:
      - name: power_consumed_live
        unique_id: power_consumed_live_id
        bucket: "envoy/autogen"
        unit_of_measurement: "W"
        range_start: "-2m"
        range_stop: "now()"
        query: >
          last()
          |> filter(fn: (r) => r["_measurement"] == "3phasepower")
          |> filter(fn: (r) => r["_field"] == "p")
          |> filter(fn: (r) => r["type"] == "total-consumption")
          |> group(columns: ["_time"])
          |> sum()

Does anyone have any suggestions for troubleshooting this?

I found my problem: I didn’t specify the port.

Isn’t it ironic that, after hours of troubleshooting, one immediately finds the solution after writing up a post about the issue…

I had the same problem, the documentation is misleading reporting “(Optional, default: 8086)”. I expected that without specifying the port it would use the default value, but it seems this is not the case.

1 Like