Syncthing As Service

Posted onby
Syncthing.service failed with result


By default, the syncthing service isn't enabled after installation. Depending onthe use-case, syncthing can be run as a system-wide service for a specific user,or as a real user-session service.


Once enabled, the syncthing service exposes a web interface (the port can bechanged in the configuration later) at address localhost:8384.

Note: With Dropbox running as a Windows Service, your files will be synchronized but you will no longer see Dropbox's graphical elements. The task tray icon, the 'overlay' icons that Dropbox places on your files in the Dropbox folder (such as the green check mark or the blue refreshing icon) and the Dropbox menu entries shown when you right. Syncthing replaces proprietary sync and cloud services with something open, trustworthy and decentralized. Your data is your data alone and you deserve to choose where it is stored, if it is shared with some third party and how it's transmitted over the Internet This package contains only the CLI program to be launched from the terminal. Syncthing is an open source file syncer that synchronises files across a network. The application can be run as a Windows Service using FireDaemon, which lets you start the application automatically at boot prior to login, start multiple instances of the application and more. The trade-off is that Syncthing is a bit trickier to manage than a service like Dropbox, which makes it painfully easy to upload, download, and sync your files across all your devices. By default, the syncthing service isn't enabled after installation. Depending on the use-case, syncthing can be run as a system-wide service for a specific user, or as a real user-session service. Once enabled, the syncthing service exposes a web interface (the port can be changed in the configuration later) at address localhost:8384.

For manual (or offline) configuration, the settings file of syncthing (XMLformat) lives at $HOME/.config/syncthing/config.xml.

An empty, default 'Sync' folder is created at the first startup in the user'shome directory.

User Session service

To enable the syncthing service as a user-session service for the current user,run:

The service will be started now and each time you log in.

The syncthing user session service will not automatically be restarted afterpackage updates. Instead, the user has to either restart syncthing from the webinterface, log out and back in, or run the following commands manually:

System service


To enable the syncthing service as a system-wide service for user USER,run:

The service will be started now and each time the system boots.

Enabling the syncthing service this way has the benefit that it will even beautomatically restarted when the syncthing package is updated by the packagemanager. The drawback of this method is that the syncthing service cannot berestarted from within the web interface (due to it being a system service).

Last month, after looking at BitTorrent Sync and realizing it wasencrypted and private, but not open source, I went digging for analternative. I found the perfect project, for me: Syncthing. Theproject is still relatively young and while it has proven to beperfectly functional, it did not come with batteries included – aninstaller package. It does come with init scripts for someenvironments, but not for Ubuntu – at least until Ubuntu transitionsto systemd. So, without further ado, here’s what I did to installSyncthing as daemon (service) under Ubuntu.

Run as:user: synct & group: synct
Service Name:syncthing
Install to:/opt/syncthing
GUI:Exposed at
Public Access:Firewall port redirect.

There’s nothing out of the ordinary about installing Syncthing as a service.Above are the details I chose for how I’d install the service. There are twopoints are worth noting. First, after the initial install the service’sconfiguration is editable through the web-gui; the XML config will be in/opt/syncthing/etc. Second, sync-able repositories do not have to live in theinstallation directory. Installing is mostly about creating the extra fluffneeded to have init start the binary.

A reminder - this is aimed at an Ubuntu system. Specifically, 14.10(Utopic) was used, although earlier versions should work too. When Ubuntutransitions to systemd as an init system, the included Upstart script will notbe applicable. (Current rumor is that the transition will be in the nextrelease – caveat emptor)

1. Create User and Group for the Daemon

The synct group provides the opportunity to add authorized users to make‘syncable’ folders with the synct group. Those users can manage theirfolder(s) with out the need for sudo/root privilege.

2. Install the Syncthing Binary


Fetch the binary from the Syncthing GitHub Project. The releases URL is: Download the tarballappropriate for your architecture. (The example uses amd64, and version0.10.18)

Start Syncthing As A Service

The only file needed from the release tarball is the executable itself. Theexecutable is tar’ed with execute permission, but it never hurts to verify itsexecutable.

4. Install an Upstart “Script”

Install the following Upstart configuration file in /etc/init/syncthing.conf

Syncthing As Service Llc


A couple of notes on the conf file:

  1. Setting the $HOME env lets syncthing know where to create the default,Sync folder on initial start-up. I had problems before I added thisstanza.

  2. Using the -home /opt/syncthing/etc flag instructs syncthing to placeall configuration files directly into the etc directory. If this flagis missing it will place the configuration in a hidden directory under$HOME.

It would be nice to get a list of supported environment variables and commandline switches, but the docs are not there yet. Conversely, I could “read thesource luke”, so I should stop whining and go contribute ;)

5. Start and Verify the Service

If the stars are aligned, then the service will start:

At this point the service is (hopefully) up. There is a small problem, however:the configuration created on first-run restricts the web-gui to loopback only( This is fine if the machine is your desktop, but can be a snag ifits remote. The config file can be edited by hand to change this.

In preparation for changing the listening address for the web-gui:

6. Modify the Configuration to expose the Web GUI

Edit the config file: /opt/syncthing/etc/config.xml

The following line should be changed as depicted. The important aspect is tochange the to the wildcard address, [The port couldbe changed too, if need be.]

Syncthing Systemd

Now restart the service

and point a web browser at port 8080 of the host.

7. (Optional) Firewall Port Redirect

At this point you have a perfectly good, working Syncthing – congratulations.

However, if your host is behind a firewall it may not be reachable forsync-ing. The first point: if you have a consumer firewall that supports UPnPthen Syncthing is likely visible as it supports, and enables by default, UPnP.If you don’t have UPnP enabled on your firewall or the Syncthing instance is notvisible then following the “Firewalls and Port Forwards” instructions on thewiki will help you resolve the issue.

In short: plumb TCP port 22000 through from your firewall to the server. Port22000 is the default port for the Block Exchange Protocol (BEP)[1], and theonly port necessary for a remote agent to connect with your server.

That’s it, you’re done. Happy syncing.

  1. The protocols Syncthing uses are documented here:↩