Difference between revisions of "Syncthing"

From ArchWiki
Jump to: navigation, search
m (Discovery Server: 'the' added)
m (Discovery Server: 'be' was missing, minor rewritting)
Line 95: Line 95:
The official documentation is provided [https://docs.syncthing.net/users/stdiscosrv.html here].  
The official documentation is provided [https://docs.syncthing.net/users/stdiscosrv.html here].  
Note that the discovery server requires certificates to run, which should ideally be placed in {{ic|/var/discosrv}}. The user/group {{ic|syncthing}} needs permissions to able to read the certificate files. Currently, you will need to edit the systemd unit file to correctly point to the certificates (as well as any other configuration changes you want to undertake, see [https://docs.syncthing.net/users/stdiscosrv.html#configuring list]).
Note that the discovery server requires certificates to run, which should ideally be placed in {{ic|/var/discosrv}}. The user/group {{ic|syncthing}} needs permissions to be able to read the certificate files. You need to edit the systemd unit file to correctly point to the certificates (and to undertake any other configuration change you may want, see [https://docs.syncthing.net/users/stdiscosrv.html#configuring list]).

Revision as of 06:59, 1 October 2017

Syncthing is an open-source file synchronization client/server application, written in Go, implementing its own, equally free Block Exchange Protocol. All transit communications between syncthing nodes are encrypted, and all nodes are uniquely identified with cryptographic certificates.


Syncthing can be installed with the syncthing package.

Synchronization by inotify can be added with either the syncthing-inotify or the syncthing-gtk package, see #Use inotify for caveats. syncthing-gtk also provides a GTK interface, desktop notifications and integration with Nautilus, Nemo and Caja.

Starting Syncthing

Note: You can run multiple copies of syncthing, but only one instance per user as syncthing locks the database to it. Check logs for errors related to locked database.

Run Syncthing

Run the syncthing binary manually from a terminal.

System service

Running Syncthing as a system service ensures that it is running at startup even if the user has no active session, it is intended to be used on a server.

Enable and start the syncthing@myuser.service where myuser is the actual name of your user.

User service

Running Syncthing as a user service ensures that Syncthing only starts after the user has logged into the system (e.g., via the graphical login screen, or ssh). Thus, the user service is intended to be used on a (multiuser) desktop computer. To use the user service, start/enable the user unit syncthing.service (i.e. with the --user flag).

The systemd services need to be started for a specific user in any case, see Autostart-syncthing with systemd for detailed information on the services.


Syncthing can also be launched by syncthing-gtk. Use interface UI settings to start syncthing-gtk at startup, and to state whether to launch the syncthing daemon.

When launching the syncthing daemon using both systemd and syncthing-gtk, it might happen that two syncthing instances run concurrently leading to high CPU consumption: one launched by syncthing-gtk, and the other (slightly later) by systemd. To solve this, either avoid launching synchting using systemd, or configure syncthing-gtk to wait for the syncthing daemon.

Accessing the web-interface

Tip: To access the configuration GUI for a remote computer, see the FAQ.

When Syncthing is started, a web interface will be provided by default on http://localhost:8384. If you started syncthing manually, it should open the admin page in your browser.


After installation Syncthing already has a proper start-up configuration. You may now add new servers and/or folders by visiting the web interface. For detailed instructions on how to set up a simple network, read Syncthing's getting started.

After a successful first start, it will create the default repository at ~/Sync. You can see this in the web admin interface. On the right is the list of nodes you have added. On the left is the list of repositories, which are folders you can choose to share with other nodes.

To add another node, click "Add Node" underneath the list of nodes. You will be prompted for their Node ID (which can be found on the other machine by clicking Edit > Show ID) as well as a short name and the address. If you specify "dynamic" for the address, the syncthing announce server will be used to automatically exchange addresses between nodes. If you want to know more about Node IDs, including the cryptographic implications, you can read the appropriate Syncthing documentation page.

After saving the configuration, you will be prompted to restart the syncthing server, and once restarted, the changes will be applied.

Next, you can either change the configuration of the default node (click its name and then Edit), or create a new one to share data with. Simply tick the node you wish to share the data with, and they will have permission to access it.

Tips and tricks

Use inotify

Note: There is no need to enable the syncthing-inotify service when using the syncthing service.

Inotify (inode notify) is a Linux kernel subsystem that acts to extend filesystems to notice changes to the filesystem, and report those changes to applications. Syncthing does not support inotify yet but there is an official extension module which talks to the Syncthing REST API. The usage of inotify avoids expensive rescans every minute. The inotify extension can be installed with the syncthing-inotify package. Restart the syncthing service for changes to take effect.

Alternatively, inotify support is provided by syncthing-gtk (which does not depend on syncthing-inotify) but in this case inotify will only work while the GUI is running.

Increase the default fs.inotify.max_user_watches value to prevent errors like Too many open files, by appending the following line:


Run a Relay

Syncthing has the ability to connect two devices via a relay when it is not possible to establish a direct connection between them. Relayed connections are end-to-end encrypted in the usual manner, so the relay has no insight into the connection other than the knowledge of the IP addresses and device IDs.

Anyone can run a relay server and it will automatically join the Syncthing relay pool and be available to all Syncthing's users. To run your own relay, install syncthing-relaysrv and Start/Enable syncthing-relaysrv.service. Rate limiting and other options can be configured via the command line. These options can be set in the ExecStart directive of the service drop-in file as follows:

ExecStart=/usr/bin/syncthing-relaysrv -global-rate 500000 -provided-by relayprovidername
Note: The relay listens by default to port 22067 for data and 22070 for service status (used for public statistics). They can be respectively overridden with the -listen and -status-srv options. These ports should therefore be open for TCP connections.
Tip: The traffic statistics of a particular relay are accessible by default on port 22070, e.g.

Stop journal spam

Syncthing can be quite noisy even while it isn't doing anything. The service ExecStart can be overridden like this to filter output directly without an extra script (adjust "grep" as needed):

ExecStart=/bin/bash -c 'set -o pipefail; /usr/bin/syncthing -no-browser -no-restart -logflags=0 | grep -v "INFO: "'

Discovery Server

The Syncthing Discovery Server is available in the AUR under syncthing-discosrvAUR. The official documentation is provided here.

Note that the discovery server requires certificates to run, which should ideally be placed in /var/discosrv. The user/group syncthing needs permissions to be able to read the certificate files. You need to edit the systemd unit file to correctly point to the certificates (and to undertake any other configuration change you may want, see list).

Description=Syncthing discovery server

ExecStart=/bin/sh -c "/usr/bin/syncthing-discosrv -db-dsn='file:///var/discosrv/discosrv.db' -cert /var/discosrv/chain.pem -key /var/discosrv/key.pem"



To point the client at your discovery server, change the Global Discovery Servers variable under Settings, to point to https://yourserver:8443/ (default port) or whatever port you have reconfigured to. The variable takes a comma-seperated list of discovery servers, it is possible to include multiple ones, including the default one.

If you are using self-signed certificates, the client will refuse to connect unless you append the discovery server ID to its domain. The ID is printed to stdout upon launching the discovery server. Amend the Global Discovery Servers entry to add the ID: https://yourserver.com:8443/?id=AAAAAAA-BBBBBBB-CCCCCCC-DDDDDDD-EEEEEEE-FFFFFFF-GGGGGGG-HHHHHHH.

Run in VirtualBox

It is possible to have Syncthing connect both locally and globally within a VirtualBox virtual machine keeping its network adapter in the standard NAT mode (rather than switching to bridged networking attached to the host computer's adapter).

To achieve this, Syncthing should use a port in the VM different from the port it uses on the host. If the default 22000 port is used by the host for listening, one could use 22001 in the VM. This is carried out by setting Syncthing's Sync Protocol Listen Addresses to tcp://:22001 in the VM and by opening the corresponding port of the virtual machine: the 22001/TCP host's port should be forwarded to the guest's same port.

In this setup, relaying should not be necessary: local devices will connect to the VM on port 22001 while global devices should be accessible as long as they have an open port.


See Debugging Syncthing.