Duplicate Key Error in configuration.yaml

I’ve encountered an error in my logs indicating a duplicate key issue: “YAML file /config/configuration.yaml contains duplicate key ‘homeassistant’ at lines 44 and 63.”

Here’s YAML configuration for reference

# Configure a default setup of Home Assistant (frontend, api, etc)
#default_config:#

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
input_number:
  ac_temperature:
    name: AC Temperature
    initial: 64
    min: 60
    max: 80
    step: 1

input_boolean:
  ac_virtual_switch:
    name: AC Virtual Switch
    initial: off

  kvm_input_one:
    name: KVM Input 1
    initial: off

  kvm_input_two:
    name: KVM Input 2
    initial: off


counter:
  bedroom_heater_activation_count:
    name: Bedroom Heater Activation Count
    initial: 0
    step: 1



http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 172.19.0.6
    - 172.18.0.6
    - 172.20.0.7
    - 172.20.0.4
    - 172.29.0.4
    - 172.18.0.7

homeassistant:
  external_url: https://hass.secret.com
  auth_mfa_modules:
    - type: totp
  auth_providers:
    - type: trusted_networks
      trusted_networks:
        - 192.168.1.224

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
automation man: !include automations-man.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
mqtt: !include mqtt.yaml
homeassistant:
  country: US
  name: Home
  unit_system: imperial
  customize: !include customize.yaml
cloud: !include cloud.yaml

I thought the solution was straightforward—simply remove one of the duplicate entries. However, after doing so and restarting, the system became unresponsive, forcing me to revert to a backup. Could someone take a look at my YAML file and suggest what I might be overlooking?

Move the four indented entries under the second homeassistant: heading to sit under the first heading, then remove the second heading.

1 Like

I think that fixed it!

I’m getting the same problem as described in the OP. Upon making those changes, when I comback to the frontend it is unresponsive, saying “unable to connect to home assistant” . The only thing that fixes it, is changing the code back to the two instances of homeassistant , and restarting the docker container.

Maybe I didn’t do as you said here is what I currently have after following your suggestions:

# Configure a default setup of Home Assistant (frontend, api, etc)
#default_config:#

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
input_number:
  ac_temperature:
    name: AC Temperature
    initial: 64
    min: 60
    max: 80
    step: 1

input_boolean:
  ac_virtual_switch:
    name: AC Virtual Switch
    initial: off

  kvm_input_one:
    name: KVM Input 1
    initial: off

  kvm_input_two:
    name: KVM Input 2
    initial: off


counter:
  bedroom_heater_activation_count:
    name: Bedroom Heater Activation Count
    initial: 0
    step: 1



http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 172.19.0.6
    - 172.18.0.6
    - 172.20.0.7
    - 172.20.0.4
    - 172.29.0.4
    - 172.18.0.7

homeassistant:
  country: US
  name: Home
  unit_system: imperial
  customize: !include customize.yaml
  external_url: https://hass.secret.com
  auth_mfa_modules:
    - type: totp
  auth_providers:
    - type: trusted_networks
      trusted_networks:
        - 192.168.1.224

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
automation man: !include automations-man.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
mqtt: !include mqtt.yaml
cloud: !include cloud.yaml

go to the config directory and open the homeassistant.log file and look in there for errors.

Concerning that you both a) appear not to have an understanding of YAML indentation and structure and b) have commented out default_config.

There are a lot of entries in here that should be set up via the UI if you aren’t comfortable with YAML — did you edit this using a very old video tutorial?

Try starting with this, then recreate your input_number, input_boolean and counter helpers via the UI. I’ve commented out your external access and MFA for now: add that back in if required once you know the internal setup works.

default_config:

homeassistant:
  customize: !include customize.yaml
#  external_url: https://hass.secret.com
#  auth_mfa_modules:
#    - type: totp
#  auth_providers:
#    - type: trusted_networks
#      trusted_networks:
#        - 192.168.1.224

group: !include groups.yaml
automation: !include automations.yaml
automation man: !include automations-man.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
mqtt: !include mqtt.yaml
cloud: !include cloud.yaml

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 172.19.0.6
    - 172.18.0.6
    - 172.20.0.7
    - 172.20.0.4
    - 172.29.0.4
    - 172.18.0.7

# Text to speech
tts:
  - platform: google_translate

1 Like

I followed your guidance and re-enabled default_config in my YAML configuration, which resolved the initial issues I was facing. After ensuring that setup was stable, I proceeded to uncomment and configure the input_number, input_boolean, and counter sections, and I’m pleased to report that they are functioning as expected now.

However, I’ve opted to leave the external access settings in a commented state for now. Interestingly, despite this, I’m still able to remotely access my Home Assistant instance using my external URL