How to autostart HA as root?

Hi,

I followed this steps to autostart HA on boot. The problem is I need to run it as root. How can I do so?

Thanks

Why are you trying to run HA as root? Running anything as root is a terrible idea.

Because of this issue:

[homeassistant.components.http] Failed to create HTTP server at port 80: [Errno 13] error while attempting to bind on address ('192.168.1.158', 80): permission denied

Only solution I found was to run HA as root :frowning:

Have you tried this https://github.com/home-assistant/home-assistant/issues/4737

Yes, I tried long ago, but it seems it’s not working for me. When I run:

sudo setcap 'cap_net_bind_service=+ep' /usr/bin/python3.4

I get:

Failed to set capabilities on file `/usr/bin/python3.4' (Invalid argument)
The value of the capability argument is not permitted for a file. Or the file is not a regular (non-symlink) file

Thanks

How do you have HA installed? What version of python are you running?

python3 --version

I am having same issue, here is my setup:

  1. Fresh install of Stretch
  2. Mosquitto (Using systemd vs init.d)
  3. Python 3.6
  4. All in one installer for HA. (using systemd)
    Everything is working fine except one issue of Autostart on reboot for HA. If I issue the restart for home-assistant service, it works fine. Just does not auto start. Any tips will be greatly appreciated.

Have you tried the command above? Replacing the python3.4 with python3.6

What does your /etc/systemd/system/[email protected] file or whatever the file is called to auto start home assistant. Mine looks like this:

pi@haven:/etc/systemd/system $ cat [email protected]
#
# Service file for systems with systemd to run Home Assistant as the 
   homeassistant user.
#

[Unit]
Description=Home Assistant for %i
After=network.target

[Service]
Type=simple
User=%i
ExecStart=/srv/homeassistant/bin/hass
SendSIGKILL=no

[Install]
WantedBy=multi-user.target

You may have to modify the path for your situation.

I did a test install using the AIO version in a VM, I had to use the following commands after creating the [email protected]

sudo systemctl enable [email protected]

then

sudo systemctl start [email protected]

to get hass running the first time, after that there was now problem auto-starting on reboot.

Yes, I did and have the config file. But still not working. It works like charm, if I type:
sudo systemctl start [email protected]

My copy of the config file:
[Unit]
Description=Home Assistant for %i
After=network.target mosquitto.service
Requires=mosquitto.service

[Service]
Type=simple
User=%i
ExecStart=/srv/homeassistant/homeassistant_venv/bin/hass -c “/home/homeassistant/.homeassistant”
SendSIGKILL=no

[Install]
WantedBy=multi-user.target

Thanks! That did the trick, although I’m on python3.5 :slight_smile: I should be ashamed of myself! What a silly mistake.

1 Like