Install Paperless-ngx on a VPS: Docker, Caddy and Valkey
Install Paperless-ngx 3 on a Debian 13 VPS: Docker Compose with PostgreSQL, Valkey and Tika, HTTPS through Caddy, backup and update, step by step.

Contents
Paperless-ngx 3.4.2PostgreSQL 18Valkey 9Caddy 2.11Docker 29.9Debian 13Paperless-ngx is a document management system you run yourself. You scan or upload letters, invoices and contracts, Paperless recognizes the text and files everything in a searchable archive. With Paperless hosted on your own server (VPS) you reach the archive from anywhere, without a cloud provider seeing your documents.
Here I install Paperless-ngx 3 on a Debian 13 server with Docker Compose. That includes PostgreSQL as the database, Valkey as the message broker, Tika and Gotenberg for Office documents, and Caddy for HTTPS. In the end everything runs at https://{{domain}}.
If you prefer a NAS, here is the guide for Synology. The Paperless-ngx guide gives you an overview of features, costs and alternatives.
Requirements
- A server running Debian 13. I use a Hetzner VPS of type CAX11 with 2 cores and 4 GB RAM. The stack uses about 1.2 GB of memory at idle, and 4 GB leaves room for text recognition. 2 GB works too, but you should set up swap.
- A user with
sudorights. - A domain, for example
{{domain}}, with an A record pointing to your server’s IP address. - Open ports 80 and 443. You need port 22 for SSH.
Install Docker
Connect to the server via SSH and install Docker with the official script:
curl -fsSL https://get.docker.com | sudo shThen check the installation:
docker --versionIf curl is missing, install it first with sudo apt install -y curl.
Create the folders
Create a directory for Paperless with a subfolder each for data, documents, export, consume folder, database and Valkey:
mkdir -p ~/paperless/{data,media,export,consume,db,valkey}
cd ~/paperlessmediaholds your documents,datathe search index and settings.exportreceives backups later.consumeis the inbox folder. Paperless picks up files that appear there automatically. How to share it for scanners is covered in the scanner guide.dbandvalkeybelong to the database containers.
The Paperless container runs with user ID 1000. Check that your user has this ID:
id -uIf the number is different, set USERMAP_UID and USERMAP_GID in the .env below to your number.
Generate credentials
Paperless needs a secret key, a database password and a password for the first user. Generate them with openssl so you do not have to invent anything. The following block writes the finished .env:
cat > .env <<EOF
PAPERLESS_URL=https://{{domain}}
PAPERLESS_SECRET_KEY=$(openssl rand -hex 32)
PAPERLESS_TIME_ZONE=Europe/Berlin
PAPERLESS_OCR_LANGUAGE=deu+eng
PAPERLESS_ADMIN_USER=admin
PAPERLESS_ADMIN_PASSWORD=$(openssl rand -hex 16)
USERMAP_UID=1000
USERMAP_GID=1000
POSTGRES_PASSWORD=$(openssl rand -hex 16)
EOFShow the file and note the admin password:
cat .env| Variable | Meaning |
|---|---|
PAPERLESS_URL |
The public address. Without it Paperless rejects logins over HTTPS. |
PAPERLESS_SECRET_KEY |
Secret key for sessions. Never share it. |
PAPERLESS_OCR_LANGUAGE |
Languages for text recognition. deu+eng detects German and English. Adjust it to your documents. |
PAPERLESS_ADMIN_USER, PAPERLESS_ADMIN_PASSWORD |
Creates an administrator on first start. |
POSTGRES_PASSWORD |
Database password. |
The file contains secrets. Never share it and never commit it to a Git repository. Set PAPERLESS_TIME_ZONE to your own time zone.
The compose.yaml
Create the file:
nano compose.yamlservices:
broker:
image: valkey/valkey:9
container_name: paperless-valkey
restart: unless-stopped
volumes:
- ./valkey:/data
db:
image: postgres:18
container_name: paperless-db
restart: unless-stopped
volumes:
- ./db:/var/lib/postgresql
environment:
POSTGRES_DB: paperless
POSTGRES_USER: paperless
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
gotenberg:
image: gotenberg/gotenberg:8.38
container_name: paperless-gotenberg
restart: unless-stopped
command:
- "gotenberg"
- "--chromium-disable-javascript=true"
- "--chromium-allow-list=^file:///tmp/.*"
tika:
image: apache/tika:3.3.1.0
container_name: paperless-tika
restart: unless-stopped
paperless:
image: ghcr.io/paperless-ngx/paperless-ngx:3.4
container_name: paperless
restart: unless-stopped
depends_on:
- db
- broker
- gotenberg
- tika
env_file: .env
environment:
PAPERLESS_REDIS: redis://broker:6379
PAPERLESS_DBHOST: db
PAPERLESS_DBPASS: ${POSTGRES_PASSWORD}
PAPERLESS_TIKA_ENABLED: 1
PAPERLESS_TIKA_GOTENBERG_ENDPOINT: http://gotenberg:3000
PAPERLESS_TIKA_ENDPOINT: http://tika:9998
volumes:
- ./data:/usr/src/paperless/data
- ./media:/usr/src/paperless/media
- ./export:/usr/src/paperless/export
- ./consume:/usr/src/paperless/consume
caddy:
image: caddy:2
container_name: caddy
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- caddy_data:/data
- caddy_config:/config
volumes:
caddy_data:
caddy_config:Save with Ctrl+O, Enter, close with Ctrl+X.
This is what each service does:
- broker is Valkey, a Redis-compatible buffer for the task queue. Paperless still calls the setting
PAPERLESS_REDIS, and the address starts withredis://. That is intended, the protocol is identical. - db is PostgreSQL 18. Since version 18 the data folder lives at
/var/lib/postgresql, no longer at/var/lib/postgresql/data. - gotenberg and tika convert Word, Excel and email files to PDFs. Without them Paperless only accepts PDFs and images.
- paperless is the application. The tag
3.4always pulls the latest version of the 3.4.x series. - caddy accepts requests on 80 and 443 and gets certificates from Let’s Encrypt.
Paperless itself publishes no port. Only Caddy is reachable from outside.
The Caddyfile
nano Caddyfile{{domain}} {
reverse_proxy paperless:8000
}Caddy forwards requests to the Paperless container. It sets up HTTPS itself as soon as the DNS record points to the server.
Start
sudo docker compose up -dThe first time, Docker downloads all images. That takes one to two minutes. Then check the status:
sudo docker compose psWait until the paperless container shows healthy in the status column. The first database initialization needs some time. To watch it:
sudo docker compose logs -f paperlessEnd the output with Ctrl+C. You see errors there right away. Often it is a wrong domain name or a missing DNS record, in which case Caddy cannot get a certificate. You see that with sudo docker compose logs caddy.
Sign in
Open https://{{domain}} in your browser. Sign in with user admin and the password from the .env.
Change the password right away: click your name at the top right, then My Profile. Enable two-factor authentication there too. The line PAPERLESS_ADMIN_PASSWORD in the .env only takes effect on first start. You can delete it afterwards.
Create a separate user for daily use (Settings → Users & Groups) and use the administrator only for administration.
The first document
Click Upload or drag a PDF into the browser window. Paperless reads the file, recognizes the text and creates a searchable copy. After a few seconds the document appears in the list:

How to file new documents automatically I show in the workflows. For a readable layout on disk see Storage paths and folder structure.
Secure the server
A publicly reachable server with sensitive documents deserves some care:
- Firewall: Allow only ports 22, 80 and 443. At Hetzner you set this in the Cloud Firewall. Docker bypasses local firewalls such as
ufwbecause it creates its own rules. So rely on your provider’s firewall. - SSH: Sign in with a key and turn off password login.
- Two-factor: Enable it in Paperless for every user.
- Updates: Keep Debian and the images current, see below.
- Restrict access: If you are the only user, you can limit access to a VPN such as WireGuard or Tailscale and not open port 443 at all.
Backup
Backups are mandatory for documents. The built-in exporter writes all documents and metadata to the export folder:
sudo docker compose exec paperless document_exporter ../exportAfterwards the export folder contains the originals, thumbnails and a manifest.json with the metadata. Copy this folder somewhere else, preferably off the server. How to automate the export is covered in Paperless backup and restore and the Ofelia backup.
A backup you have never restored is untested. Try the restore on a second server.
Update
In the ~/paperless folder, pull the images and restart:
sudo docker compose pull
sudo docker compose up -dThe tag 3.4 delivers all patch versions of the 3.4 series automatically. To move to a new series, such as 3.5, change the tag in the compose.yaml. Read the release notes first and make a backup.
Never just swap the PostgreSQL major version in the tag. That requires a migration, as this post describes.
Common mistakes
The page does not load or shows a certificate warning. The DNS record does not point to the server, or port 80 is closed. Caddy needs both to get the certificate.
Sign-in fails with “CSRF”. PAPERLESS_URL does not match the address in the browser. Check spelling and https://.
The paperless container keeps restarting. Look at the log. Often permissions are missing in the data or media folder. Set them to your user, for example with sudo chown -R 1000:1000 data media export consume.
Office files are rejected. Check that the tika and gotenberg containers are running and the three PAPERLESS_TIKA_* settings are in the compose.yaml.
FAQ
Frequently asked questions
How much RAM does Paperless-ngx need?
The full stack with PostgreSQL, Valkey, Tika, Gotenberg and Caddy uses about 1.2 GB at idle. Plan for 4 GB so text recognition has room for larger documents. 2 GB works with swap.
Why Valkey instead of Redis?
Valkey is a free fork of Redis and speaks the same protocol. Paperless-ngx works with it unchanged. The setting is still called PAPERLESS_REDIS.
Do I need Tika and Gotenberg?
Only if you want to store Word, Excel, PowerPoint or email files. For PDFs and images, Paperless, the database and the broker are enough.
How do I change the admin password?
Sign in, open My Profile at the top right and change the password there. The variable PAPERLESS_ADMIN_PASSWORD only takes effect on first start.
How do I update Paperless-ngx?
In the folder with the compose.yaml run sudo docker compose pull and then sudo docker compose up -d. Make a backup with document_exporter first.
Can I run Paperless-ngx without a domain?
Yes, but only on the local network or through a VPN. For HTTPS through Caddy and Let's Encrypt you need a domain.
Changelog
Rewritten for Paperless-ngx 3.4: Debian 13, Docker Compose with PostgreSQL 18 and Valkey 9 instead of Redis, Caddy without WireGuard, credentials generated with openssl, backup with document_exporter, update notes and server hardening.