Connection to InfluxDB fails

Hi mates,
Hope you are all doing good, I am taking some time to work on my home assistant project and have few problem setting up influxdb.

I am following this tutorial as it seems to be the best I could find, adapting it with my project.

My problem is HA is not talking to influxdb though Grafana can see it and communicate with it. Of course I cannot make any useful chart as HA is not filling influxdb with my sensors data.
I have HA, Influxdb, Grafana (and Node-red, Deconz) install using docker. I am not using Hassio

cat Home_Assistant/.HA_VERSION 
0.106.6

At startup, I can see in the HA logs the influxdb service is starting but fails to connect :

2020-03-25 19:20:58 INFO (MainThread) [homeassistant.setup] Setting up influxdb
2020-03-25 19:20:58 INFO (MainThread) [homeassistant.setup] Setting up lovelace
2020-03-25 19:20:58 INFO (MainThread) [homeassistant.setup] Setup of domain lovelace took 0.0 seconds.
2020-03-25 19:20:58 INFO (MainThread) [homeassistant.setup] Setting up updater
2020-03-25 19:20:58 INFO (MainThread) [homeassistant.setup] Setting up zone
2020-03-25 19:20:58 INFO (MainThread) [homeassistant.setup] Setting up sun
2020-03-25 19:20:58 WARNING (SyncWorker_9) [homeassistant.components.influxdb] Database host is not accessible due to 'HTTPConnectionPool(host='192.168.1.251', port=8086): Max retries exceeded with url: /write?db=home_assistant (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f206b45b490>: Failed to establish a new connection: [Errno 111] Connection refused'))', please check your entries in the configuration file (host, port, etc.) and verify that the database exists and is READ/WRITE. Retrying again in 60 seconds.

The last line makes me think home assistant is trying to use the deprecated webui to connect but I am not so sure.
My HA config.yaml :

influxdb:
  host: 192.168.1.251
  port: 8086
  database: home_assistant
  max_retries: 10
  include:
    entities:
       # Batteries
       - sensor.bout1_salon_xiaomi_battery_level
       - sensor.bout5_salon_ikea_battery_level
       - sensor.temp_salon_battery_level 
       # Temperatures
       - sensor.temp_salon
       # Humidite
       - sensor.humid_salon
       # Pression
       - sensor.press_salon 

I can access the databased through command line of course and Grafana but not HA.
What could be wrong ?

Just in case, my docker-compose file :

version: '3'
services:

  homeassistant:
    container_name: home-assistant
    image: homeassistant/home-assistant:stable
    restart: always
    ports:
      - "8123:8123"
    volumes:
      - /opt/Docker/Home_Assistant/:/config
    devices:
      - /dev/ttyZWAVE:/dev/ttyACM0
    environment:
      - TZ=Europe/Paris
    network_mode: host

  nodered:
    container_name: node-red
    restart: unless-stopped
    image: nodered/node-red:latest
    depends_on:
      - "homeassistant"
    user: root
    volumes:
      - /opt/Docker/Node_Red/:/data
    ports:
      - "1880:1880"

  deconz:
    image: marthoc/deconz
    container_name: deconz
    restart: always
    ports:
      - "8080:8080"
      - "5900:5900"
    volumes:
      - /opt/Docker/Deconz:/root/.local/share/dresden-elektronik/deCONZ
    devices:
      - /dev/ttyACM0
    environment:
      - DECONZ_WEB_PORT=8080
      - DECONZ_WS_PORT=4443
      - DEBUG_INFO=1
      - DEBUG_APS=0
      - DEBUG_ZCL=0
      - DEBUG_ZDP=0
      - DEBUG_OTAU=0
      - DECONZ_DEVICE=/dev/ttyACM0
    network_mode: host

  influxdb:
    container_name: influxdb
    restart: always
    ports:
      - '8086:8086'
      - '8083:8083'
    volumes:
      - '/opt/Docker/Influxdb/:/var/lib/influxdb'
    image: influxdb
    network_mode: host

  grafana:
    ports:
      - '3000:3000'
    container_name: grafana
    volumes:
      - '/opt/Docker/Grafana:/var/lib/grafana'
    image: grafana/grafana
    network_mode: host

Any idea on what could be wrong ?
I was planning on writing a French tutorial on HA installation and all but I think I am not auite ready as I cannot figure out this problem on my own… :sob:
Cheers,

This is my influx.db configuration :

influxdb:  
  host: 10.0.0.67
  port: 8086
  username: xxx
  password: xxx
  max_retries: 3
  default_measurement: state  
  include:
    entities:
      - sensor.temp_keuken_humidity 
      - sensor.temp_keuken_temperature
      - sensor.temp_slaapkamer_temperature      
      - sensor.temp_slaapkamer_humidity
      - sensor.eetkamer_temperature      
      - sensor.eetkamer_humidity
  component_config_glob:
    sensor.*humidity:
      override_measurement: humidity
    sensor.*temperature:
      override_measurement: temperature
    sensor.*hum:
      override_measurement: humidity
    sensor.*temp:
      override_measurement: temperature      
      

I see you didn’t configure a user or password

Thanks for sharing your file. I did not set credentials as everything is available locally only.
Plus is is easier to debug.
My grafana can connect so I don’t think a user & password couple is needed, but I could be wrong.I’ll try

The error message is reporting a failure to connect to IP address 192.168.1.251, but your configuration code is showing 192.168.1.253. Is there something to that?

Unrelated, but if you are using host network mode the port mappings are ignored, FYI.

I miss typed the ip but it is both. 251 written
No problem there

I use the host network mode because it is the only one that seems to go through my firewall.I know port mapping are ignore but is is just a useful way to remember(and find when forgotten) which ports are used :sweat_smile:

I tired to change the influxdb to add a loggin/password but I cannot figure out how to acess it.
it is supposed to be in the /etc/influxdb/influxdb.conf but I cannot bind that to the permanent config file of influxdb…

So I really do not know how to attack this problem. to me it does not make sense that Grafana can access influx successfully but not HA

So I have added a home_assistant user to influx with a password, added it to HA configuration.yaml but nothing changes :frowning_face:
it must be something else but I do not have enough knowledge on how HA works to understand

Hum, I think adding

    depends_on:
      - "influxdb"

in my docker-compose file, in the HA section solved the problem. Maybe influx was starting too late ?