# Reconnecting Peers Periodically

**Reconnecting Periodically |** [**Medium Article**](https://medium.com/pinata/how-to-keep-your-ipfs-nodes-connected-and-ensure-fast-content-discovery-7d92fb23da46)

Peers have a tendency to disconnect from each other if not reconnected manually periodically, so to combat this, you may add the following two files to periodically reconnect to your swarm peers.

```
sudo su -
cat <<EOF > /lib/systemd/system/gateway-connector.service
[Unit]
Description=Job that periodically connects this IPFS node to the gateway node
[Service]
ExecStart=/usr/local/bin/ipfs swarm connect <ADD_MULTIPLE_CONNECTIONS_HERE_SPACE_SEPARATED> # /ip4/52.70.167.190/tcp/4001/ipfs/QmZ5gLTZwvfD5DkbbaFFX4YJCi7f4C5oQAgq8qpjL8S1ur /ip4/34.224.152.33/tcp/4001/ipfs/QmcCX4b3EF3eXaDe5dgxTL9mXbyci4FwcJAjWqpub5vCXM
Environment="IPFS_PATH=/root/.ipfs"
EOF
exit
```

```
sudo su -
cat <<EOF > /lib/systemd/system/gateway-connector.timer
[Unit]
Description=Timer that periodically triggers gateway-connector.service
[Timer]
OnBootSec=3min
OnUnitActiveSec=1min
[Install]
WantedBy=timers.target
EOF
exit
```

Now you can enable and start the service:

```
sudo systemctl enable gateway-connector.timer
sudo systemctl start gateway-connector.timer
```

To double checked this worked, run:

```
systemctl list-timers
```

You should see an entry for your gateway connector service. You can also check the status of its last execution attempt by running:

```
systemctl status gateway-connector
```

Finally you can monitor the process with:

```
journalctl -f | grep ipfs
```
