# IPFS Daemon keeps getting killed

**URL:** <https://discuss.ipfs.tech/t/ipfs-daemon-keeps-getting-killed/7084>\
**Category:** Help\
**Tags:** go-ipfs\
**Created:** [January 22, 2020, 5:52pm UTC](https://discuss.ipfs.tech/t/ipfs-daemon-keeps-getting-killed/7084 "2020-01-22T17:52:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vasa-develop](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/vasa-develop/32/1749_2.png) [@vasa-develop](https://discuss.ipfs.tech/u/vasa-develop)\
**Post date:** [January 22, 2020, 5:52pm UTC](https://discuss.ipfs.tech/t/ipfs-daemon-keeps-getting-killed/7084/1 "2020-01-22T17:52:39Z")

</div>

I’m using go-ipfs version `0.4.22`.

I’m running `nohup ipfs daemon &` to keep the node up on a server. But somehow it’s getting killed frequently.

A strange thing I noticed in the logs was this:

```auto
Initializing daemon...
go-ipfs version: 0.4.22-
Repo version: 7
System version: amd64/linux
Golang version: go1.12.7
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/172.31.40.167/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/172.31.40.167/tcp/4001
Swarm announcing /ip6/::1/tcp/4001
API server listening on /ip4/127.0.0.1/tcp/5001
WebUI: http://127.0.0.1:5001/webui
Gateway (readonly) server listening on /ip4/0.0.0.0/tcp/8080
Daemon is ready

Received interrupt signal, shutting down...
(Hit ctrl-c again to force-shutdown the daemon.)
19:59:56.490 ERROR core: failure on stop: context canceled builder.go:47

```

The interrupt part usually comes 5-6hr after I start the daemon.  
But I haven’t hit `CTRL+C`, also no one else has access to the server.  
Any idea how this could happen?

---

<div class="post-metadata">

**Author:** ![hector](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/hector/32/178_2.png) [@hector](https://discuss.ipfs.tech/u/hector)\
**Post date:** [January 22, 2020, 7:28pm UTC](https://discuss.ipfs.tech/t/ipfs-daemon-keeps-getting-killed/7084/2 "2020-01-22T19:28:18Z")

</div>

It seems your daemon gets killed right away? I can’t reproduce this, `nohup` seems to work for me.

I guess [you could hack a way to know where the signal is coming from](https://stackoverflow.com/questions/8400530/how-can-i-tell-in-linux-which-process-sent-my-process-a-signal), but otherwise the canonical way of doing what you want to do is a systemd service: [https://github.com/ipfs/go-ipfs/tree/164dd287bef18ba3a4a684d52cfbeb41446c3b54/misc/systemd](https://github.com/ipfs/go-ipfs/tree/164dd287bef18ba3a4a684d52cfbeb41446c3b54/misc/systemd)

---

<div class="post-metadata">

**Author:** ![vasa-develop](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/vasa-develop/32/1749_2.png) [@vasa-develop](https://discuss.ipfs.tech/u/vasa-develop)\
**Post date:** [January 22, 2020, 7:57pm UTC](https://discuss.ipfs.tech/t/ipfs-daemon-keeps-getting-killed/7084/3 "2020-01-22T19:57:10Z")

</div>

Thanks for this. I will use `systemd` instead.🙂

P.S. I updated the logs in the question for more clarity.

---

<div class="post-metadata">

**Author:** ![vasa-develop](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/vasa-develop/32/1749_2.png) [@vasa-develop](https://discuss.ipfs.tech/u/vasa-develop)\
**Post date:** [January 22, 2020, 8:37pm UTC](https://discuss.ipfs.tech/t/ipfs-daemon-keeps-getting-killed/7084/4 "2020-01-22T20:37:39Z")

</div>

I just tried running ipfs daemon with `systemd` and got the following error

```auto
Jan 22 20:17:08 ip-172-31-40-167 ipfs[27219]: WebUI: http://127.0.0.1:5001/webui
Jan 22 20:17:08 ip-172-31-40-167 ipfs[27219]: Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080
Jan 22 20:17:08 ip-172-31-40-167 ipfs[27219]: Daemon is ready
Jan 22 20:18:37 ip-172-31-40-167 systemd[1]: ipfs.service: Start operation timed out. Terminating.
Jan 22 20:18:37 ip-172-31-40-167 ipfs[27219]: Received interrupt signal, shutting down...
Jan 22 20:18:37 ip-172-31-40-167 ipfs[27219]: (Hit ctrl-c again to force-shutdown the daemon.)
Jan 22 20:18:37 ip-172-31-40-167 ipfs[27219]: 20:18:37.060 ERROR core: failure on stop: context canceled builder.go:47
Jan 22 20:18:37 ip-172-31-40-167 systemd[1]: Failed to start IPFS Daemon.
Jan 22 20:18:37 ip-172-31-40-167 systemd[1]: ipfs.service: Unit entered failed state.
Jan 22 20:18:37 ip-172-31-40-167 systemd[1]: ipfs.service: Failed with result 'timeout'.

```

But this time it got killed in a minute(see timestamps in the log). I will dig deeper into this. Maybe I’m just doing something silly here.

---

<div class="post-metadata">

**Author:** ![stebalien](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/stebalien/32/156_2.png) [@stebalien](https://discuss.ipfs.tech/u/stebalien)\
**Post date:** [January 23, 2020, 1:53pm UTC](https://discuss.ipfs.tech/t/ipfs-daemon-keeps-getting-killed/7084/5 "2020-01-23T13:53:19Z")

</div>

What’s your systemd service file definition? I see you’re using IPFS 0.4.22 but I’m guessing you may be using the systemd service definition from go-ipfs master.

The service definition in go-ipfs master expects the daemon to report a successful start via systemd’s notification system (Type=notify). If it doesn’t, systemd will think the unit has failed to start and will kill it.

Removing the `Type=notify` line from the service definition should fix this.

---

<div class="post-metadata">

**Author:** ![vasa-develop](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/vasa-develop/32/1749_2.png) [@vasa-develop](https://discuss.ipfs.tech/u/vasa-develop)\
**Post date:** [January 23, 2020, 2:42pm UTC](https://discuss.ipfs.tech/t/ipfs-daemon-keeps-getting-killed/7084/6 "2020-01-23T14:42:51Z")

</div>

Thanks @stebalien!

That worked. Although, I needed to execute `sudo systemctl daemon-reload` as the system was picking the old `ExecStart`.

Here is the working `systemd` file:

```auto
[Unit]
Description=IPFS Daemon

[Service]
ExecStart=/usr/local/bin/ipfs daemon
KillSignal=SIGINT

[Install]
WantedBy=default.target

```
