
Deploy Syncthing | (Just Updated) Continuous File Synchronization Server, GUI And REST API Locked From Boot
Syncthing file synchronization server with REST API, web GUI and volume
syncthing
Just deployed
/var/syncthing
Deploy and Host Syncthing on Railway
Built for an LLM agent to deploy and use. The deploy form has nothing to fill in: the web GUI login and the REST API key are generated, the GUI is locked behind a login from the first boot, and the device identity, configuration and synced files survive redeploys on a volume. Syncthing is open-source continuous file synchronization between devices, with a web GUI and a REST API.
About Hosting Syncthing
This template runs one service from the upstream Syncthing image (version 2.1.7), pinned by digest. Everything Syncthing keeps (device key and certificate, configuration, index database and the default Sync folder) lives on one volume mounted at /var/syncthing. Railway mounts a volume owned by root while Syncthing runs as an unprivileged user, so the start command fixes the ownership of the volume first.
No open GUI. A stock Syncthing starts with no GUI login, which on a public domain would hand the whole instance to the first visitor. The start command sets the GUI login (user admin) from the generated SYNCTHING_GUI_PASSWORD on every boot, and fixes the REST API key to the generated SYNCTHING_API_KEY, so both stay the same across redeploys. There is no account registration in Syncthing: the one login is the one generated for you.
What the template fixes for Railway. The web GUI and REST API listen on Railway's injected PORT, which is also the port the healthcheck dials.
Connecting other devices. The sync listener (port 22000) is not published, because Railway cannot share one service between an HTTP healthcheck and a TCP proxy. This instance reaches your other devices outbound through Syncthing's global discovery and public relays; add the device ID shown in the GUI on the other side. Direct inbound connections to this service are not available.
Using it. Open the service domain, sign in as admin with SYNCTHING_GUI_PASSWORD (read it from the syncthing service variables), then add devices and folders. For an agent, use the REST API with the API key as in the contract below.
Agent contract
- Public URL:
SYNCTHING_PUBLIC_URLon thesyncthingservice (the generated https address of the service) - Private URL:
http://syncthing.railway.internal:8080 - Credentials: the variables
SYNCTHING_API_KEY(REST API) andSYNCTHING_GUI_PASSWORD(web GUI, useradmin) on thesyncthingservice - Auth: REST calls send the header
X-API-Keywith the value ofSYNCTHING_API_KEY; HTTP Basic is not accepted on/rest. The web GUI signs in withPOST /rest/noauth/auth/passwordand a JSON body holdingusernameadminandpasswordfromSYNCTHING_GUI_PASSWORD, which answers204and sets a session cookie; a wrong login answers403. A request with no key or a wrong one answers403, sowrite without key: 403. - Health:
GET /rest/noauth/healthreturns 200
#!/bin/sh
# needs: SYNCTHING_PUBLIC_URL, SYNCTHING_API_KEY, SYNCTHING_GUI_PASSWORD (variables of the syncthing service); also curl
# signup: none - Syncthing has no account registration; the one GUI login is generated at boot, so there is nothing to sign up to
R="$SYNCTHING_PUBLIC_URL"; K="X-API-Key: $SYNCTHING_API_KEY"; J="Content-Type: application/json"
n=0; until [ "$(curl -s -o /dev/null -w '%{http_code}' "$R/rest/noauth/health")" = 200 ]; do n=$((n+1)); [ "$n" -le 60 ] || break; sleep 5; done
curl -s -o /dev/null -w "health: %{http_code}\n" "$R/rest/noauth/health"
curl -s -H "$K" "$R/rest/system/status" | grep -c '"myID"' | sed 's/^/status with key (1 = device id returned): /'
# write with the key: add a folder, read it back, remove it
curl -s -o /dev/null -w "create folder: %{http_code}\n" -H "$K" -H "$J" -d '{"id":"railway-check","label":"railway-check","path":"/var/syncthing/railway-check","type":"sendreceive"}' "$R/rest/config/folders"
curl -s -H "$K" "$R/rest/config/folders/railway-check" | grep -c '"id": "railway-check"' | sed 's/^/folder found after write: /'
curl -s -o /dev/null -w "delete folder: %{http_code}\n" -X DELETE -H "$K" "$R/rest/config/folders/railway-check"
# the web GUI login (user admin) answers with a session cookie
curl -s -o /dev/null -w "gui login: %{http_code}\n" -H "$J" -d "{\"username\":\"admin\",\"password\":\"$SYNCTHING_GUI_PASSWORD\"}" "$R/rest/noauth/auth/password"
curl -s -o /dev/null -w "gui login wrong password: %{http_code}\n" -H "$J" -d '{"username":"admin","password":"wrong"}' "$R/rest/noauth/auth/password"
curl -s -o /dev/null -w "read without key: %{http_code}\n" "$R/rest/system/status"
curl -s -o /dev/null -w "write without key: %{http_code}\n" -H "$J" -d '{"id":"anonymous","path":"/tmp/anonymous"}' "$R/rest/config/folders"
curl -s -o /dev/null -w "write wrong key: %{http_code}\n" -H "X-API-Key: wrong" -H "$J" -d '{"id":"anonymous","path":"/tmp/anonymous"}' "$R/rest/config/folders"
A fresh deploy prints health: 200, status with key (1 = device id returned): 1, create folder: 200, folder found after write: 1, delete folder: 200 and gui login: 204. The refusals print gui login wrong password: 403, read without key: 403, write without key: 403 and write wrong key: 403: a request with no key or a wrong one creates nothing.
Why Deploy Syncthing on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying Syncthing on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
- Agent-ready - generated GUI login and API key, a contract block and one script that proves the REST API, folder create, read and delete, the GUI login, and the refusal of a read and a write with no key or a wrong one.
- No open GUI - the login is set at boot, so the first visitor gets nothing.
- Data survives redeploys - device identity, configuration and files sit on a volume, with the right ownership set at boot.
- Always-on peer - an always-online device other devices can sync through.
- Pinned - the upstream image is pinned by digest.
Common Use Cases
- Always-on sync hub - keep one online copy so laptops and phones sync even when they are never on at the same time.
- Off-site backup target - mirror a folder from a home machine to a copy kept elsewhere.
- Self-hosted Dropbox alternative - sync folders across your devices with no third-party storage.
- File exchange for AI agents - an agent drives folders and devices over the REST API.
Dependencies for Syncthing Hosting
- The one
syncthingservice created by the template with its/var/syncthingvolume. Nothing else is required.
Deployment Dependencies
Template Content
syncthing
ghcr.io/syncthing/syncthing:2.1.7