Syncthing does not autostart (Linux)

I am running Mageia 9, and I have not been able to make Syncthing autostart. I have tried the following configurations:

1 Using XDG autostart:

~/.local/bin/syncthing (executable)

~/.local/share/applications/syncthing-start.desktop (desktop file modified for executable path)

~/.config/autostart/syncthing-start.desktop (symlink to desktop file)

2 Using systemd user service:

~/.local/bin/syncthing (executable)

~/.config/systemd/user/syncthing.service (service file modified for executable path, using %h and absolute)

Both of these methods work for other applications and the problem persists across multiple computers. Attempts to write a log file have been unsuccessful. It runs normally if started manually.

$ syncthing --version
syncthing v1.29.2 "Gold Grasshopper" (go1.23.4 linux-amd64) builder@github.syncthing.net 2025-01-11 16:38:29 UTC

Just to make sure I understand, there are no Syncthing log entries when it fails? And no systemd log entries when using that method? If you use the —-logfile command-line option in your configuration, does that change anything?

Yes, that’s correct.

  • If I use --logfile=~/.var/log/syncthing in the desktop file, it does not create any file there.
  • $ journalctl -u syncthing returns “no entries”. (This is also true for my other user service that works, so perhaps I have made an error here.)
  • If I start the syncthing manually, the GUI log viewer shows nothing from previous runs, and nothing obviously unusual.
1 Like

I sure have no idea what’s going on here.

Because generally speaking this would require logging in and not logging off in order for Syncthing to continue running, using systemd is a better choice.

What is the output from systemctl --user status syncthing?

Would you mind sharing the contents of~/.config/systemd/user/syncthing.service?

Oh, thanks, that does get me something:

$ systemctl --user status syncthing
â—‹ syncthing.service - Syncthing - Open Source Continuous File Synchronization
     Loaded: loaded (/home/ian/.config/systemd/user/syncthing.service; disabled; preset: disabled)
     Active: inactive (dead)
       Docs: man:syncthing(1)

The service file is stock, but modified to point at the (absolute) path:

[Unit]
Description=Syncthing - Open Source Continuous File Synchronization
Documentation=man:syncthing(1)
StartLimitIntervalSec=60
StartLimitBurst=4

[Service]
ExecStart=/home/ian/.local/bin/syncthing serve --no-browser --no-restart --logflags=0
Restart=on-failure
RestartSec=1
SuccessExitStatus=3 4
RestartForceExitStatus=3 4

# Hardening
SystemCallArchitectures=native
MemoryDenyWriteExecute=true
NoNewPrivileges=true

# Elevated permissions to sync ownership (disabled by default),
# see https://docs.syncthing.net/advanced/folder-sync-ownership
#AmbientCapabilities=CAP_CHOWN CAP_FOWNER

[Install]
WantedBy=default.target

For my purposes, XDG autostart would be sufficient, if it can be made to work.

Are you using an encrypted home directory?

No, I am not.

You didn’t indicated how you used the user systemd service, aka enabling or starting. The status output shows it’s disabled, so it wont start on loging as expected. What happens is you run systemd --user start syncthing? There should then be logs, or if your systemd logging setup is borked, the status command should show some info. Also just for good measure I’d try commenting out the hardening options.

As already mentioned, your Syncthing service isn’t enabled to autostart at login or at boot time.

To enable the Syncthing service to autostart for your user account:

systemctl --user enable syncthing

Note that the above command will only autostart Syncthing during log in, and will also stop Syncthing when you log off. So if you want Syncthing to autostart at boot time and also persist when you log off, tell systemd’s login manager to allow it:

loginctl enable-linger

Looks like your version of syncthing.service is a bit outdated, so although it’s not the reason for the autostart issue, it’d be worth updating to the latest revision: https://github.com/syncthing/syncthing/blob/main/etc/linux-systemd/system/syncthing%40.service

1 Like

Thanks! I had been missing sytemctl --user enable syncthing and now everything seems to work. Not sure why my other user service didn’t need that, nor what was wrong with the XDG autostart (this had been my go-to in the past), but these are both questions for another time.

2 Likes

:slightly_smiling_face:… It’s an easy and common one to miss because it seems like adding the service unit file would be enough, similar to XDG’s autostart.

On my NAS, I start Syncthing at boot time with a syncthing.timer unit file that adds a 15-minute delay to give the OS a chance to take care of any filesystem errors first.

For XDG, it could be the desktop environment, because not all support it.

For anyone following along in the future:

Looks like your version of syncthing.service is a bit outdated,

This is a wrong link. For the syncthing user service, this is the correct file: syncthing/etc/linux-systemd/user/syncthing.service at main · syncthing/syncthing · GitHub

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