How to Install Syncthing on Debian 8 Server to Back Up Website

This tutorial will teach you how to install Syncthing on Debian 8 server and use it to back up your Web site.

Syncthing is a free continuous file synchronization that lets you synchronize your files across multiple devices. It’s an open source alternative to the popular BitTorrent Sync (aka btsync) application. The creation, modification or deletion of files on one machine will automatically be replicated to your other devices. Syncthing does not upload your data to the cloud but exchange your data directly between your devices. All your data is encrypted when transmitting between your devices.

Install Syncthing on Debian 8  via Official Deb Repository

Use curl to download the GPG key then import the key with apt-key.

sudo apt-get install curl

curl -s | sudo apt-key add -

-s option enables silent mode.

If you see OK in the terminal, that means the GPG key is successfully imported. Then add official deb repository with the following command.

echo "deb syncthing release" | sudo tee /etc/apt/sources.list.d/syncthing.list

Update local package index and install syncthing on Debian 8.

sudo apt-get update

sudo apt-get install syncthing

Using Systemd to Set Up Syncthing as a System Service

Since we are installing Syncthing on a server, we set up Syncthing as a system service to ensure that Syncthing is run at startup even without an active user session.

The Syncthing system service must be started for a user with a home directory because Syncthing needs to store configuration files under the user’s home directory. To keep our Debian 8 system tidy and clean, we create a system user named syncthing with a home directory using the below command:

sudo useradd -r syncthing -m -d /home/syncthing

-r option is used to create a system user. -m option tells useradd to create a home directory. -d option specifies the home directory.

Under /lib/systemd/system/ directory, you will find a [email protected] file. Enable syncthing to auto start when Debian 8 is booted up by running the below command.

sudo systemctl enable [email protected]

The first syncthing is the service name; the second syncthing is the user we created earlier. The above command will create a symbolic link that points to the [email protected] file.

/etc/systemd/system/[email protected] -> /lib/systemd/system/[email protected]

Now let’s start the syncthing service with the following command.

sudo systemctl start [email protected]

Check status

systemctl status [email protected]


[email protected] - Syncthing - Open Source Continuous File Synchronization for syncthing
  Loaded: loaded (/lib/systemd/system/[email protected]; enabled)
  Active: active (running) since Fri 2016-05-27 06:36:34 EDT; 10s ago
    Docs: man:syncthing(1)
Main PID: 24150 (syncthing)
  CGroup: /system.slice/system-syncthing.slice/[email protected]
  └─24150 /usr/bin/syncthing -no-browser -no-restart -logflags=0

You can see that Syncthing is enabled and it’s running as syncthing user.

The syncthing system service creates configuration files under /home/syncthing/.config/syncthing/ and a folder /home/syncthing/Sync as the default sync folder. The main config file is .config/syncthing/config.xml.

By default, Syncthing service listens on We can use curl to see if it’s working.

curl -I


HTTP/1.1 200 OK
Cache-Control: public
Content-Length: 40319
Content-Type: text/html
Last-Modified: Fri, 27 May 2016 10:11:53 GMT
Set-Cookie: CSRF-Token-UG3ZG=xaVUtKc32uQRNKFHxLFvDb7pTJzhgbmC
X-Syncthing-Version: v0.13.4
Date: Fri, 27 May 2016 10:20:17 GMT

Accessing the Syncthing Web Interface

Since it listens on, Syncthing Web interface is only available to connections from the same computer. To be able to access the Syncthing Web interface from a remote computer, we can use Nginx to set up a reverse proxy for Syncthing. First install Nginx if haven’t already done so.

sudo apt-get install nginx

Then create a server config file. Replace with your preferred domain name.

sudo nano /etc/nginx/conf.d/

Add the following content to this file. Replace with your preferred domain name.

server {
  listen 80;

  root /usr/share/nginx/syncthing;
  access_log /var/log/nginx/;
  error_log /var/log/nginx/;
  location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;

Save and close the file. Then create the Web root for syncthing.

sudo mkdir /usr/share/nginx/syncthing

Test Nginx configuration and reload Nginx.

sudo nginx -t

sudo systemctl reload nginx

After you point your domain name to the IP address of Debian 8 server, type your domain name in the browser address bar and you should see the Syncthing Web interface.

syncthing web interface

Secure the Syncthing Web GUI

Install a TLS/SSL Certificate

To obtain a free TLS/SSL certificate from Let’s Encrypt with Nginx on a Debian 8 server. Follow the below instructions.

First, we need to install the Let’s Encrypt client which is available for Debian 8 from jessie-backports repository. Open sources.list file with nano text editor.

sudo nano /etc/apt/sources.list

Then add the following line at the end of this file.

deb jessie-backports main

Update local package index and install letsencrypt.

sudo apt-get update

sudo apt-get install letsencrypt -t jessie-backports

Now we can use the Let’s Encrypt client to obtain a free TLS/SSL certificate. Run the below command:

sudo letsencrypt certonly --email <your-email-address> -d --webroot -w /usr/share/nginx/syncthing

The subcommmand certonly tells letsencrypt client to obtain a certificate, but do not install it because letsencrypt client doesn’t support auto-configuration for Nginx at time of writing.

--webroot flag tells letsencrypt client to use the Webroot plugin.

Replace <your-email-address> with your real email address. Replace with your real domain name.

-w is short for --webroot-path. /usr/share/nginx/syncthing is the Web root for syncthing.

Within a few seconds, you should see a congrats message like below.

Congratulations! Your certificate and chain have been saved at
/etc/letsencrypt/live/ Your cert
will expire on 2016-08-23. To obtain a new version of the
certificate in the future, simply run Let's Encrypt again.

If you see a 403 forbidden or 404 not found error after running the above command, that’s probably because your Nginx configuration doesn’t allow access to hidden files. To enable access to /usr/share/nginx/syncthing/.well-known/acme-challenge, add the following directive to the /etc/nginx/conf.d/ file.

location ~ /.well-known/acme-challenge {
    allow all;

Then reload Nginx configuration.

sudo systemctl reload nginx

And run the letsencrypt command again to obtain your certificate.

Once the certificate is obtained, let’s configure Nginx TLS/SSL settings. Open /etc/nginx/conf.d/ again.

sudo nano /etc/nginx/conf.d/

Change the content of this file to the following. Replace with your real domain name.

server {
  listen 80;
  return 301$request_uri;
server {
  listen 443 ssl;

  ssl on;
  ssl_session_timeout 1d;
  ssl_session_cache shared:SSL:10m;
  ssl_session_tickets off;
  ssl_protocols TLSv1.1 TLSv1.2;

  ssl_prefer_server_ciphers on;
  ssl_certificate /etc/letsencrypt/live/;
  ssl_certificate_key /etc/letsencrypt/live/;

  root /usr/share/nginx/syncthing;
  access_log /var/log/nginx/;
  error_log /var/log/nginx/;
  location / { 
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header X-Forwarded-Proto $scheme;

Save and close the file. Now reload Nginx.

sudo systemctl reload nginx

Refresh your Syncthing Web GUI, you will find HTTP connection is automatically redirected to HTTPS secure connection. Please note that using obsolete or improper SSL configuration can lead to Web browser’s refusal to establish a connection.

Password Protect

The above configuration allows anyone to access the Web interface. We can set up a username and password by clicking the Actions button on the upper-right corner, then select Settings.

install syncthing on Debian 8

On the right side of the Settings window, enter a username in GUI Authentication User field, enter a password in GUI Authentication Password field. Then save your settings.

syncthing username and password

Please note that you don’t want to check Use HTTPS for GUI which enables Syncthing to use a self-signed certificate. We have already installed a valid certificate which is trusted by mainstream Web browsers.

After pressing the Save button, we must restart Syncthing system service for the changes to take effect, otherwise you will see 502 bad gateway error when reloading the page.

sudo systemctl restart [email protected]

Now log into the Syncthing Web interface with your new username and password.

Start Syncing Files between Your Servers

Now we finished setting up one Debian 8 server, we also need to install Syncthing and configure it on a second Debian 8 server.

Once we have two Debian 8 servers running Syncthing, we need to add each of the server to the device list. Open the Syncthing Web interface of the first Debian 8 server, click on Actions > Show ID on the upper-right corner. You will see the device ID of the first server which is a long string of letters and numbers. The QR code, which is also the device ID, is used for configuring syncthing on smart phones.

Syncthing Device ID

Copy the device ID, then open the Syncthing Web interface of the second server, click Add Remote Device on the bottom-right corner. Then paste the Device ID and give the device it a name. Click the Save button.

Syncthing add remote device

Now we have the first server in the device list of the second server. The second server will try to connect to the first server. Refresh the Web interface of the first server, you will see the following message. Click Add Device to add the second server to the device list of the first server.

Syncthing add device

Now the two servers are connected.

One the left pane of Web interface is the default sync folder (/home/syncthing/Sync). To back up your Web site, click Add Folder button.

syncthing add folder

Give a descriptive label for the folder. Select the folder path of your Web site such as /var/www/html. In the Share with Devices section, put a check mark before the device to share your Web root with this device.

Syncthing share folder

In the advanced settings, you can change the sync frequency which is 60 seconds by default. You can also set Folder Type to Master. In Master mode, all changes from the other device is ignored. If changes happened on the other device, then the folder becomes out of sync. In that case, you can click a Override Changes button to enforce the master’s current state to the other device. Changes on the other device will be overwritten by the version on the master, files that don’t exist on the master will be removed.

Syncthing advanced settings

Click Save button to begin syncing.

If you see a permission denied error like below, then you need to grant write permission of your Web root to the syncthing user.


Run the following command to grant read, write and execute permissions.

sudo apt-get install acl

sudo setfacl -R -m "u:syncthing:rwx" /var/www/html

Then refresh the Web interface, you will see Syncthing is scanning the folder. A message also appears in the Web interface of the other device. Click Add to receive files.

syncthing add share folder

Now the two server are syncing files. On the right side you can see the download rate, upload rate, RAM usage, CPU usage, etc. The syncing process is pretty fast.

syncthing sycning progress

I hope this post helped you to install Syncthing on Debian 8 server and back up your Web site. Comments, questions or suggestions are always welcome. If you think this post is useful, 🙂 please share it!

Rate this tutorial
[Total: 7 Average: 4.9]

6 Responses to “How to Install Syncthing on Debian 8 Server to Back Up Website

  • Luke Fabish
    3 years ago


    Super-useful article thanks. One thing: to get nginx to serve syncthing I had to move the syncthing.yourdomein.etc from /etc/nginx/config.d to /etc/nginx/sites-available and then create a link to it in /etc/nginx/sites-enabled (I’m on wheezy, not sure if that makes a difference)

    • Xiao Guo-An (Admin)
      3 years ago

      Hi, To get Nginx serve config files under /etc/nginx/conf.d/ directory, you simply need to add the following directive in the http section of /etc/nginx/nginx.conf file.

      include /etc/nginx/conf.d/*.conf;

      And then reload Nginx

      sudo service nginx reload

  • Manuel
    1 year ago

    Thanks for the great tutorial! As a variant without nginx, one can also enable network access to the WebGUI by changing the listening address in /home/syncthing/.config/syncthing/config.xml from to and then setting user authentication and/or https in the WebGUI. (See

  • For another alternative to accessing the web gui, which usually is needed only occasionally one can simply create a temporary tunnel to the server:

    ssh -N -L 8888:localhost:8384 your.server.domain

    and then just open the browser at


    after doing your work, simply press ctrl+c in the terminal.

    This way there is no safety risk in running a steady server for occasional accessing the gui.

  • Instead of nginx, you can edit the


    … and change the address tag withing the gui tag to:

    That makes the GUI accessible from more than just the local upon which syncthing is installed.

    Really great tutorial. Thank you for the effort. Much appreciated.

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community ( for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.