Syncthing systemd service will not start

I’m trying to set up Syncthing on three of my computers: a server/media center (running Debian), a desktop, and a laptop (both running Manjaro). To do this, I was following this guide. For the Debian machine, I ran the commands in the guide to add the repository and install. For the Manjaro machines, I installed Syncthing using PacMan. Running which syncthing on all three machines returns /usr/bin/syncthing.

Now… I can start Syncthing with no issues by simply calling syncthing. I can access the browser GUI, and all is good there. My problem is when I try to add the systemd unit. Per the guide I am following, I ran these commands on all three machines:

 sudo chown root: syncthing@.service
 sudo mv syncthing@.service /etc/systemd/system
 sudo systemctl daemon-reload
 sudo systemctl enable syncthing@<user>
 sudo systemctl start syncthing@<user>

Replacing with the proper username.

When I check the status of the unit on my server with systemctl status syncthing@alfred.service I get this output:

syncthing@alfred.service - Syncthing - Open Source Continuous File Synchronization for alfred
   Loaded: loaded (/etc/systemd/system/syncthing@.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Sat 2021-02-20 18:55:06 EST; 4s ago
     Docs: man:syncthing(1)
  Process: 1677 ExecStart=/usr/bin/syncthing serve --no-browser --no-restart --logflags=0 (code=exited, status=2)
 Main PID: 1677 (code=exited, status=2)

It always says activating (auto-restart) and I can’t access the GUI at localhost:8384. This is the same on all machines. I don’t know what the problem is but I’m pretty sure it’s something to do with the .service file I downloaded from github and the (code=exited, status=2). I’ve done some searching online but found nothing helpful. I’m not very familiar with systemd.

This indicates to me that the services failed and was restarted. Do you have any errors in the journal?

journalctl --no-host --no-pager -b -u syncthing@alfred.service

The service includes some hardening options, you might want to remove them to to check if this is the problem. But first check the journal.

Copied “user.lib/systemd/user/syncthing.service” to “user/lib/systemd/system”
Then “sudo systemctl enable --now syncthing”
This appears to work

Thank you @xabbu , that command lead me to this clue which helped me solve the issue…

Feb 20 19:20:18 systemd[1]: syncthing@alfred.service: Main process exited, code=exited, status=2/INVALIDARGUMENT

The INVALIDARGUMENT made me think there might be something wrong with the value of ExecStart in the syncthing@.service file. I checked the Syncthing manpage and found no mention of the serve argument anywhere. Also, the option flags in the manpage have a single leading -, not double. I stopped the service and edited the file. I removed the serve argument and changed the options to have one leading dash and saved the file. Then ran:

sudo systemctl daemon-reload
sudo systemctl enable syncthing@alfred
sudo systemctl start syncthing@alfred

Huzzah! It works! :tada:

● syncthing@alfred.service - Syncthing - Open Source Continuous File Synchronization for alfred
   Loaded: loaded (/etc/systemd/system/syncthing@.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2021-02-20 19:20:33 EST; 31min ago
     Docs: man:syncthing(1)
 Main PID: 4231 (syncthing)
    Tasks: 19 (limit: 4915)
   Memory: 32.3M

You know, I normally never blindly follow guides and copy-paste commands I don’t understand. This is another reminder of why I don’t do that. Also, note to self: learn systemd.

Man, I am so glad I found this thread. I had the same issue and was quite confused, since the exact same steps to configure a user-based syncthing service worked last year. I looked into it a bit and found that the changes were made based on this:

Apparently the systemd config files were changed recently to account for an upcoming release (v1.15) where the commandline options will be changing (where serve and the double dashes will be necessary). So if you @el_maquinisto update to that version when it releases (sometime in April), your config will break again.

Oh great! :laughing: well I’ll just bookmark this post so I get reminded next month. :smiley: Thanks for the info.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.