Install and deploy
Telegram Media Downloader is one tgdl-server process with the dashboard embedded in the binary. ffmpeg (for thumbnails, seekbar previews and video work) is the only external program it calls. Face recognition and NSFW scanning are optional sidecar containers. Pick one of these ways to run it:
| Option | Best for | Needs |
|---|---|---|
| Docker Compose | Servers, NAS, most people | Docker with Compose |
| Release binary | A plain Linux, Windows or macOS machine | ffmpeg |
| Scoop | Windows, installed and updated by Scoop | Scoop (ffmpeg optional) |
| From a git checkout | Upgraded 2.x checkouts, PM2 users | ffmpeg; Go only to build yourself |
All of them need a Telegram apiId and apiHash from my.telegram.org, which you paste into the dashboard after the first sign-in.
Docker Compose
mkdir telegram-media-downloader && cd telegram-media-downloader
mkdir -p data
curl -fsSLO https://raw.githubusercontent.com/botnick/telegram-media-downloader/main/docker-compose.yml
docker compose up -d
docker compose logs -f telegram-downloader
What you get:
telegram-downloaderruns the multi-arch imageghcr.io/botnick/telegram-media-downloader:latest(linux/amd64 and linux/arm64) on port3000. All state lives in./data, mounted at/app/data. Change the host port withTGDL_PORTin.env.autohealrestarts the container if/healthstops answering.watchtowerupdates the containers carrying its label (all four, itself included) when you press Install update, or automatically on a schedule whenWATCHTOWER_HTTP_API_PERIODIC_POLLS=trueis set in.env. It has no published port.
The entrypoint starts as root only to fix ownership of the data folder and to join the group of a passed-through /dev/dri, then runs the server as the unprivileged node user (uid 1000, as in 2.x). Both the image and the Compose file allow 60 seconds for a clean shutdown.
Optional settings go in a .env file next to docker-compose.yml; start from .env.example and see Configuration.
Synology: download docker-compose.synology.yml instead, adjust the data volume path, and start it the same way (Container Manager project or docker compose -f docker-compose.synology.yml up -d).
To build the image from source, replace the image: and pull_policy: lines in docker-compose.yml with build: . inside a git checkout.
Optional AI sidecars
Seekbar previews need nothing extra. For NSFW scanning, both compose files contain a commented tgdl-nsfw service: uncomment it and the volumes: block at the end of the file, set TGDL_NSFW_SIDECAR_URL=http://tgdl-nsfw:8012 in .env, and run docker compose up -d. Face recognition uses the tgdl-faces container in the same way. Leaving them commented changes nothing. Setup, tokens and GPU images: AI.
First dashboard password
For safety, the first password can only be set from the machine itself.
- Same machine, no Docker: open
http://localhost:3000and use the setup form. - Docker or a remote server: put the password on one line in a private file (8 characters minimum, readable only by you) and run:
docker compose exec -T -u node telegram-downloader tgdl-server setup --password-stdin < /path/to/password-file
# Without Docker, next to the running server:
PORT=3000 ./tgdl-server setup --password-stdin < /path/to/password-file
Delete the file afterwards and sign in at http://<host>:3000. The command talks to the running server over loopback. It never accepts a password as an argument and cannot replace an existing password; change the password later from the dashboard.
Then:
- Settings → Telegram API: paste
apiIdandapiHash. - Settings → Accounts → Add: phone number and login code, or Sign in with a QR code instead and scan it from the Telegram app (Settings → Devices → Link Desktop Device); then the 2FA password if the account has one.
- Chats: turn on the monitor for a chat, start a backfill, or paste a
t.me/link.
Release binary
Each release has tgdl-server-v<version>-<os>-<arch>.tar.gz archives for Linux (amd64, arm64, arm, 386), Windows (amd64, arm64) and macOS (amd64, arm64), plus a SHA256SUMS file.
VERSION=3.11.2
curl -fsSLO https://github.com/botnick/telegram-media-downloader/releases/download/v$VERSION/tgdl-server-v$VERSION-linux-amd64.tar.gz
curl -fsSLO https://github.com/botnick/telegram-media-downloader/releases/download/v$VERSION/SHA256SUMS
sha256sum --ignore-missing -c SHA256SUMS
tar -xzf tgdl-server-v$VERSION-linux-amd64.tar.gz
TGDL_DATA_DIR=./data PORT=3000 ./tgdl-server
Install ffmpeg from your package manager for thumbnails, or point FFMPEG_PATH at it. ./tgdl-server help lists the commands (setup, backup-restore, backup-decrypt, backup-oauth, version).
Windows with Scoop
On Windows, Scoop installs and updates the release binary. This repository is the Scoop bucket:
scoop bucket add tgdl https://github.com/botnick/telegram-media-downloader
scoop install tgdl/tgdl-server
scoop install ffmpeg # optional: thumbnails and video previews
tgdl-server # in a NEW terminal; then open http://localhost:3000
Open a new terminal after the first install so it sees TGDL_DATA_DIR.
- Updating:
scoop update tgdl-server(orscoop update *) replaces only the program. - Where the data lives: the manifest sets
TGDL_DATA_DIRto~\scoop\persist\tgdl-server\data(settings, database, Telegram sessions and downloads). Updates andscoop uninstall tgdl-serverleave it in place; onlyscoop uninstall --purgeremoves it. - Moving from a manual install: set
TGDL_DATA_DIRto your existing data folder instead, or copy that folder to the path above before the first start. - Other settings:
PORT,TGDL_BIND_HOSTand the other variables in Configuration work as usual. - Service: the server runs in the console. To keep it running in the background, use the Task Scheduler (“At log on”, start
tgdl-server) or a service wrapper such as NSSM. - Manifest:
bucket/tgdl-server.jsonis updated after each release (scripts/update-scoop.py <version>). Scoop may take a few minutes to see a new version.
systemd
[Unit]
Description=Telegram Media Downloader
After=network-online.target
Wants=network-online.target
[Service]
User=tgdl
Group=tgdl
Environment=TGDL_DATA_DIR=/var/lib/telegram-media-downloader
Environment=PORT=3000
ExecStart=/opt/telegram-media-downloader/tgdl-server
Restart=on-failure
RestartSec=5
TimeoutStopSec=60
[Install]
WantedBy=multi-user.target
From a git checkout
git clone https://github.com/botnick/telegram-media-downloader.git
cd telegram-media-downloader
./runner.sh # Windows: run_safe.bat (or watchdog.ps1)
When core-service/tgdl-server is missing or older than the checkout, the launcher downloads the matching release archive, verifies it against SHA256SUMS and installs it, so no Go toolchain is needed. Data goes to ./data unless TGDL_DATA_DIR is set. npm start and pm2 start ecosystem.config.cjs call the same launcher (they only need the node command for the small wrapper script).
The launchers do not restart a crashed server; use systemd, PM2 or the Windows task scheduler for that. Set TGDL_SERVER_BIN to run your own build.
Build from source
Needs Go 1.26.
make build # writes core-service/tgdl-server
./runner.sh # or: TGDL_DATA_DIR=./data core-service/tgdl-server
Reverse proxy and HTTPS
Put a reverse proxy in front when the dashboard is reachable from outside your network. Forward the WebSocket upgrade headers and set:
TGDL_SECURE_COOKIES=1once the dashboard is served over HTTPS;TRUST_PROXYto match your proxy (the Compose file uses1, one hop);TGDL_BIND_HOST=127.0.0.1for a native install with the proxy on the same host, so the port is not reachable directly.
Caddy:
tgdl.example.com {
reverse_proxy 127.0.0.1:3000
}
nginx:
server {
listen 443 ssl;
server_name tgdl.example.com;
# ssl_certificate / ssl_certificate_key ...
client_max_body_size 0;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 1h;
}
}
Updating
- Dashboard (Docker): Settings → Maintenance → Install update. It checks the database, saves a verified snapshot to
data/backups/db-pre-update-*.sqlite, then asks watchtower to recreate the container. - Docker, automatically: put
WATCHTOWER_HTTP_API_PERIODIC_POLLS=truein.env(and optionallyWATCHTOWER_SCHEDULE, a 6-field cron; default0 0 4 * * *, daily at 04:00), thendocker compose up -d. The app, autoheal and watchtower itself are kept current; the download queue survives the restart and the monitor resumes on its own. - Docker, by hand:
docker compose pull && docker compose up -d - Release binary: replace
tgdl-serverwith the new one and restart. - Git checkout:
git pull, then restart; the launcher fetches the matching binary.
The dashboard shows when a newer release is out (it checks GitHub releases). Migrations are idempotent and run before /health reports ready. Coming from 2.x? Read Upgrading from 2.x.