Error: Failed to connect to local LXD: Get http://unix.socket/1.0: EOF

I installed LXD in my ubuntu 18.
It works ok for two days but later I start having this error when I try to do any lxd or lxc call
i.e.
lxd init

Error: Failed to connect to local LXD: Get http://unix.socket/1.0: EOF

I tried with sudo, but I get same error. The only different (I dont think it can be the problem) is that I am using a different network that I used when I installed it.

Is that the snap or the deb?

If snap, try: journalctl -u snap.lxd.daemon -n 300
If deb, try: journalctl -u lxd -n 300

That should tell us a bit more about what’s going on.

Thanks @stgraber for your reply.

It is deb, I did:
journalctl -u lxd -n 300

I got:
“CGroup memory swap accounting is disabled, swap limits will be ignored.”

I checked this thread

I added swapaccount=1 in GRUB_CMDLINE_LINUX_DEFAULT but I am still getting the same error.

I am a little bit lost with /proc/cmdline, where is it?

Thank you in advance.

That warning is unrelated.

Can you try:

  • systemctl stop lxd.service lxd.socket
  • lxd --debug --group lxd

Ok,
I got some errors:

EROR[02-17|16:16:22] Cannot listen on https socket, skipping… err=“listen tcp [ip]:8443: bind: cannot assign requested address”
INFO[02-17|16:16:22] Starting /dev/lxd handler:
INFO[02-17|16:16:22] - binding devlxd socket socket=/var/lib/lxd/devlxd/sock
INFO[02-17|16:16:22] REST API daemon:
INFO[02-17|16:16:22] - binding Unix socket socket=/var/lib/lxd/unix.socket
INFO[02-17|16:16:22] Initializing global database
WARN[02-17|16:16:27] Raft: Heartbeat timeout from “” reached, starting election
DBUG[02-17|16:16:27] Raft: Node at [ip]:8443 [Candidate] entering Candidate state in term 155
DBUG[02-17|16:16:27] Raft: Votes needed: 1
DBUG[02-17|16:16:27] Raft: Vote granted from 1 in term 155. Tally: 1
DBUG[02-17|16:16:27] Raft: Election won. Tally: 1
DBUG[02-17|16:16:27] Raft: Node at [ip]:8443 [Leader] entering Leader state
DBUG[02-17|16:16:27] Dqlite: server connection failed err=failed to establish network connection: Head https://[ip]:8443/internal/database: context deadline exceeded address=[ip]:8443 attempt=0

The [ip] is not the same ip that I am using here. It can be the problem?

Yes, sounds like you’ve configured LXD to use an IP you don’t have on your system.
It’s also hard to tell, but if clustering was ever enabled on this machine, then that’ll be a bit tricky to fixup.

Anyway, easiest way to get LXD running is by adding that IP to your loopback device temporarily:

  • sudo ip -4 addr add IP/32 dev lo

Then LXD should start fine, at which point you should update core.https_address to something more relevant. If your IP is likely to change often, then just using :8443 would avoid this issue by always listening on port 8443, regardless of address.

Thanks. I did it.
am not getting the same error. But when I do some lxd calling, it take too much time and finally dies.

When I debug, I get:

DBUG[02-18|08:58:37] Connecting to a local LXD over a Unix socket
DBUG[02-18|08:58:37] Sending request to LXD method=GET url=http://unix.socket/1.0 etag=
INFO[02-18|09:08:07] LXD 3.0.3 is starting in normal mode path=/var/lib/lxd
INFO[02-18|09:08:07] Kernel uid/gid map:
INFO[02-18|09:08:07] - u 0 0 4294967295
INFO[02-18|09:08:07] - g 0 0 4294967295
INFO[02-18|09:08:07] Configured LXD uid/gid map:
INFO[02-18|09:08:07] - u 0 165536 65536
INFO[02-18|09:08:07] - g 0 165536 65536
INFO[02-18|09:08:07] Kernel features:
INFO[02-18|09:08:07] - netnsid-based network retrieval: no
INFO[02-18|09:08:07] - unprivileged file capabilities: yes
INFO[02-18|09:08:07] Initializing local database
DBUG[02-18|09:08:07] Initializing database gateway
DBUG[02-18|09:08:07] Start database node id=1 address=[ip]:8443
DBUG[02-18|09:08:07] Raft: Restored from snapshot 5-9433-1550002038708
DBUG[02-18|09:08:07] Raft: Initial configuration (index=1): [{Suffrage:Voter ID:1 Address:0}]
DBUG[02-18|09:08:07] Raft: Node at [ip]:8443 [Follower] entering Follower state (Leader: “”)
DBUG[02-18|09:08:07] Dqlite: starting event loop
DBUG[02-18|09:08:07] Dqlite: accepting connections
DBUG[02-18|09:08:07] Connecting to a local LXD over a Unix socket
DBUG[02-18|09:08:07] Sending request to LXD method=GET url=http://unix.socket/1.0 etag=
WARN[02-18|09:08:10] Raft: Heartbeat timeout from “” reached, starting election
DBUG[02-18|09:08:10] Raft: Node at [ip]:8443 [Candidate] entering Candidate state in term 164
DBUG[02-18|09:08:10] Raft: Votes needed: 1
DBUG[02-18|09:08:10] Raft: Vote granted from 1 in term 164. Tally: 1
DBUG[02-18|09:08:10] Raft: Election won. Tally: 1
DBUG[02-18|09:08:10] Raft: Node at [ip]:8443 [Leader] entering Leader state

@stgraber Finally I remove lxd and I re-insalled and now it works ok.
Thank you for your help.