Monday, 16 January 2017

Homebridge, autostart with systemd

Updated 2017-10-08 !

systemd is service manger which autostart jobs and it will even

               restart the homebridge job if it fails  

!!! Disable any other homebridge autostart job before You enable systemd  !!! 

If You followed my earlier setup the homebridge command is placed in


If You used another setup check with 

$ which homebridge

so the path in file ”homebridge.service” will be correct


Create the service file for systemd

$ sudo nano /etc/systemd/system/homebridge.service

and add the following configuration

Description=Node.js HomeKit Server
# Could be /usr/local/bin/homebridge

Then the following commands to get it up and running

$ sudo systemctl daemon-reload
$ sudo systemctl enable homebridge
Created symlink from /etc/systemd/system/
 to /etc/systemd/system/homebridge.service.
$ sudo systemctl start homebridge

With the following command 

$ sudo systemctl status homebridge -l

You will get something like this if You succeed 

$ sudo systemctl status homebridge
homebridge.service - Node.js HomeKit Server
   Loaded: loaded (/etc/systemd/system/homebridge.service; enabled)
   Active: active (running) since Mon 2017-01-16 18:37:23 UTC; 2min 49s ago
 Main PID: 3047 (homebridge)
   CGroup: /system.slice/homebridge.service
           └─3047 homebridge

This setup is picked up from

and from homebridge

but changed a little to do it as simple as possible.
I know that this solution is not best practice and if the setup fails it is hard to debug. But sometimes simplicity wins, or ? 

If You have problems and would like to clean up, use the following commands 

$ sudo systemctl stop homebridge
$ sudo systemctl disable homebridge

and then delete the ”homebridge.service” file.


  1. Hur vet man att homebridge hittar config filen enligt exemplet ovan?

  2. Since the systemd service manager is executing as "pi" and Homebridge(HB) is installed with "pi" it will look for the "config.json" in the default location. The same as if You execute the HB command on a command line.

  3. Thanks for quick replies. Do you mean default location for systemd or homebridge?

  4. Is systemd your preferred way to run homebridge now?

  5. Default location for homebridge "config.json". I think that systemd allways is the preferred way to start any background job, since it take cares of any failure and restarts the job. But it could be easier to set up......

  6. Tack för hjälpen med detta, fungerar utmärkt!
    Kan rekommendera Homekit-pluginet för Node-Red, värt att testa på!