Setup Homebridge to Start on Bootup

I’ve recently been playing with Homebridge on my Raspberry Pi. I’ve setup my Harmony Hub and my wireless power outlets to be controlled by Siri on my iPhone. Overall it has been pretty simple to setup but I did run into an issue trying to get Homebridge to start on bootup. Homebridge suggest 3 different methods

I decided to use systemd to start Homebridge on bootup. I prefered this method because it will restart if an error occurs. I followed the gist setup step by step but ran into some problems.

My main issues were:

  • The location of my homebridge binary. Step 2
  • Permissions were not correct and the service failed to load. Step 7
  • I needed the persist folder in /var/homebridge directory. Step 6

Here are the steps that worked for me:

  1. sudo nano /etc/default/homebridge and paste this gist
  2. sudo nano /etc/systemd/system/homebridge.service and paste this gist
    1. I had to remove local from:  ExecStart=/usr/local/bin/homebridge $HOMEBRIDGE_OPTS  because my homebridge installed in /usr/bin/
  3. Create a user to run service: sudo useradd --system homebridge
  4. sudo mkdir /var/homebridge
  5. sudo cp ~/.homebridge/config.json /var/homebridge/
    1. This copies your current user’s config. This assumes you have already added accessories etc.
  6. sudo cp -r ~/.homebridge/persist /var/homebridge
  7. sudo chmod -R 0777 /var/homebridge
  8. sudo systemctl daemon-reload
  9. sudo systemctl enable homebridge
  10. sudo systemctl start homebridge

Type systemctl status homebridge to check the status of the service.

Hopefully this helps anyone who is having trouble with Homebridge starting on boot on a Raspberry Pi. Please comment below if you have any questions.

Also published on Medium.

269 thoughts to “Setup Homebridge to Start on Bootup”

  1. Hi Tim, I to am a newbie, but was able get through your instructions with no issues. Thank you. Just one question… Where do I go to find the output of the executing homebridge?

    Thanks john

  2. Tim,

    Thanks so much for this tutorial.

    I ran into one issue on Step 9

    Once i entered: sudo systemctl enable homebridge
    I got this response: Failed to enable unit: Invalid argument

    All the commands I entered up to step 9 worked fine.

    Any idea what caused the Invalid Argument? i’m using a newer Rpi with the latest software.
    I have homebridge running well and just wanted it to boot on launch.

    Any help is appreciated. Regards,

  3. Anybody ever tried to save every data from homebridge accessories (temperature, door open/close/ motion) and save them on a sheet or on a server ?

  4. Hello! small question if you don’t mind regarding the point5:

    sudo cp ~/.homebridge/config.json /var/homebridge/

    Does it mean that each time an accessory is added to the ~/.homebridge/config.json file, the config file in /var/homebridge/ has to be updated manually as well??


  5. On reboot the “Smartthings” accessory not working but nest is working.

    after I reboot, if I disable these and enable again then working
    sudo systemctl enable homebridge
    sudo systemctl start homebridge

    any help please?

  6. Everything works great, but when I want to add additional plug ins or update the config.json, do I update both config.json locations or just /var/homebridge? Do I add plugins the normal way (i.e. npm – g install homebridge-plugin)? Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *