permission denied on installing lxd via snap

2.2k Views Asked by At

I'm trying to install LXD on my Ubuntu via this tutorial https://docs.conjure-up.io/devel/en/user-manual#users-of-lxd in it says I have to follow these steps:

  1. sudo snap install lxd (no problem in installing)
  2. /snap/bin/lxd init (I get the below error)

Error: Failed to connect to local LXD: Get http://unix.socket/1.0: dial unix /var/snap/lxd/common/lxd/unix.socket: connect: permission denied

can anyone tell me how to fix it?

2

There are 2 best solutions below

6
Rico On BEST ANSWER

Looks like for some reason the permissions on the unix.socket are not correct. (I tried this myself and works fine). The permission on my unix.socket look like this:

srw-rw----  1 root lxd     0 Nov  7 18:02 unix.socket

I would try:

sudo chown root:lxd /var/snap/lxd/common/lxd/unix.socket
sudo chmod 664 /var/snap/lxd/common/lxd/unix.socket
sudo chmod u+s /var/snap/lxd/common/lxd/unix.socket

If not then it could be an issue with your /var/snap/lxd/common/lxd/ directory. Does it even exist?

0
Philipp On

Proper way according to Ubuntu page is:

  1. sudo apt install lxd
  2. sudo lxd init
  3. sudo adduser <your-user> lxd
  4. newgrp lxd

Now you are ready to launch:

  • lxc launch ubuntu:22.04 test