Score:1

Can’t start IPFS daemon - ipfs.service: Failed with result ‘exit-code’

kp flag

Even though I'm a noob, I decided to launch a new AWS Ubuntu instance for my IPFS node and encountering errors.

I followed this tutorial - https://medium.com/textileio/tutorial-setting-up-an-ipfs-peer-part-i-de48239d82e0 and I have the ipfs.service below

[Unit]
Description=ipfs daemon
[Service]
ExecStart=/usr/local/bin/ipfs daemon --enable-gc
Restart=on-failure
RestartSec=5
User=ubuntu
Group=ubuntu
Environment="IPFS_PATH=/data/ipfs"
[Install]
WantedBy=multi-user.target

But I keep getting this...

ubuntu@ip-172-31-35-57:~$ sudo systemctl status ipfs
● ipfs.service - ipfs daemon
     Loaded: loaded (/etc/systemd/system/ipfs.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Mon 2023-08-14 01:25:54 UTC; 3s ago
    Process: 78949 ExecStart=/usr/local/bin/ipfs daemon --enable-gc (code=exited, status=1/FAILURE)
   Main PID: 78949 (code=exited, status=1/FAILURE)
        CPU: 67ms

When I run the command /usr/local/bin/ipfs daemon --enable-gc independently, it seems to work fine. But I’m not sure why the service refused to work.

The syslog says this...

Aug 14 13:49:10 ip-172-31-35-57 systemd[1]: Started ipfs daemon.
Aug 14 13:49:10 ip-172-31-35-57 ipfs[218510]: Initializing daemon...
Aug 14 13:49:10 ip-172-31-35-57 ipfs[218510]: Kubo version: 0.22.0
Aug 14 13:49:10 ip-172-31-35-57 ipfs[218510]: Repo version: 14
Aug 14 13:49:10 ip-172-31-35-57 ipfs[218510]: System version: amd64/linux
Aug 14 13:49:10 ip-172-31-35-57 ipfs[218510]: Golang version: go1.19.12
Aug 14 13:49:10 ip-172-31-35-57 ipfs[218510]: Error: no IPFS repo found in /data/ipfs.
Aug 14 13:49:10 ip-172-31-35-57 ipfs[218510]: please run: 'ipfs init'
Aug 14 13:49:10 ip-172-31-35-57 systemd[1]: ipfs.service: Main process exited, code=exited, status=1/FAILURE
Aug 14 13:49:10 ip-172-31-35-57 systemd[1]: ipfs.service: Failed with result 'exit-code'.

But when I ran ipfs init, I get this.

ubuntu@ip-172-31-35-57:~$ ipfs init
generating ED25519 keypair...done
peer identity: 12D3KooWQt2nmHF...
initializing IPFS node at /home/ubuntu/.ipfs
Error: ipfs configuration file already exists!
Reinitializing would overwrite your keys
Artur Meinild avatar
vn flag
Isn't there some log entries in the bottom of `systemctl status ipfs` also? Please include this, log entries are often useful.
bafew80778 avatar
kp flag
@ArturMeinild I just added the log
bafew80778 avatar
kp flag
@ArturMeinild It worked. Thank you. But no idea why when I use $HOME, the path changed to /root. I'm logged in as ubuntu as user.
Artur Meinild avatar
vn flag
Maybe because `systemd`executes its service as root. Also, I've added my comment as answer.
Raffa avatar
jp flag
If you want `$HOME` to expand to your logged-in user instead of the `root`'s home directory, then use a [user service](https://askubuntu.com/a/1475900)
Score:1
vn flag

It seems there is a discrepancy between where ifps is initialized, and where the systemd unit the configuration to exist.

To make the configuration line up, do one of two things:

  1. Run ipfs init inside /data/ipfs
    (to make the data dir /data/ipfs).
  2. Set Environment="IPFS_PATH=/home/ubuntu" in the ipfs.service file
    (to make the data dir /home/ubuntu)
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.