Paperless-ngx Setup: Docker, OCR and Document Backups

14 min read

,
Paperless-ngx Setup: Docker, OCR and Document Backups

Paperless-ngx makes scanned bills, receipts and other documents searchable on your own server. It uses OCR to read the text, then lets you organise files by correspondent, document type and tags. Keep an inbox for new scans so you can check the dates and labels before trusting the archive.

The Docker setup below uses PostgreSQL, with optional Tika and Gotenberg services for additional file formats. Start with a few test documents, check the OCR results and configure an off-server backup before importing your full archive.

Why Paperless-ngx is worth the setup

Bills and personal records often end up scattered across paper folders, email and phone photos. There is the paper file with property papers and insurance policies, a Gmail inbox full of PDF bills, a WhatsApp chat with photos of receipts, and a folder of Form 16s and ITR acknowledgements somewhere on a laptop. Finding one specific document under pressure, for a visa application, a loan, or an insurance claim, is the moment that system breaks.

Paperless-ngx fixes that by putting everything in one place and making it searchable by content, not just file name.

  • OCR on everything. Scanned paper and photographed receipts become searchable text. The original is kept, and an archived PDF/A copy with a text layer is created.
  • Automatic organisation. Tags, correspondents (who sent it) and document types are assigned by rules or by a classifier that learns from your corrections.
  • Many ways in. Upload in the browser, drop files into a watched folder, scan straight to a network share, or pull attachments from email.
  • Local storage. Your archive stays on the server you manage. Optional AI backends and other connected services can send document content elsewhere, so check their settings before using private records.
Diagram of how Paperless-ngx turns documents into a searchable archive. Files can arrive as a browser upload, a drop into a watched consume folder, a scan to a network share, or an email attachment. OCR turns scanned paper and photographed receipts into searchable text; the original is kept, and an archived PDF/A copy with a text layer is created. Tags, correspondents and document types are assigned by rules or by a classifier that learns from your corrections. Everything stays on your server, searchable by content. Paperless-ngx is private by default, which matters for documents carrying Aadhaar, PAN, bank account and medical details
Image: Techzei

Paperless-ngx compared with the usual options

FeaturePaperless-ngxGoogle Drive or OneDriveFolders on a NAS
Full-text search inside scansYes, OCR on importPartial, varies by file typeNo
Automatic tags and correspondentsYes, rules and learningNoNo
Import from emailYes, mail rulesManualManual
Where data livesYour serverProvider’s cloudYour server
CostFree, open sourceFree tier, then subscriptionFree beyond hardware
Setup effortMediumNoneLow

If you already run a home server or NAS, Paperless-ngx sits naturally next to tools like Immich. Our Google Photos to Immich guide follows the same idea for photos.

What you need before you start

  • A machine that is always on. A mini PC, NAS that runs Docker, or a Raspberry Pi 4 or 5 with 4 GB of RAM or more. OCR is CPU-heavy, so faster hardware means faster imports.
  • Docker and Docker Compose. Install Docker Engine from docs.docker.com, or use your NAS’s container app.
  • Storage. Plan for a few gigabytes per thousand documents, plus space for backups on a separate disk.
  • A way to scan. A document scanner with scan-to-folder or scan-to-email support is ideal. A phone scanning app that saves PDFs also works.
  • About 30 minutes.

Step 1: Choose a database and install method

Paperless-ngx offers several Docker Compose templates. The documentation recommends PostgreSQL for new installations, and the -tika variants add Apache Tika and Gotenberg so Paperless can also handle Office documents and emails.

TemplateDatabaseOffice files and .emlBest for
docker-compose.postgres-tika.ymlPostgreSQLYesMost new installs on a mini PC or NAS
docker-compose.postgres.ymlPostgreSQLNoPDFs and images only
docker-compose.sqlite.ymlSQLiteNoRaspberry Pi and small archives
docker-compose.sqlite-tika.ymlSQLiteYesSmall archives with Office files

There are two install routes.

Route A: the official install script. It asks a few questions, downloads the right compose files, pulls the images, starts the containers and creates your superuser. Inspect the script first if piping from the internet into a shell makes you uneasy:

bash -c "$(curl --location --silent --show-error https://raw.githubusercontent.com/paperless-ngx/paperless-ngx/main/install-paperless-ngx.sh)"

Route B: the compose files by hand. This gives you full control and is what the rest of this guide uses.

Step 2: Download the compose files

Create a folder for Paperless and download the PostgreSQL and Tika template, saved as docker-compose.yml, together with the two environment files:

mkdir -p ~/paperless && cd ~/paperless
curl -L -o docker-compose.yml https://raw.githubusercontent.com/paperless-ngx/paperless-ngx/main/docker/compose/docker-compose.postgres-tika.yml
curl -L -O https://raw.githubusercontent.com/paperless-ngx/paperless-ngx/main/docker/compose/docker-compose.env
curl -L -O https://raw.githubusercontent.com/paperless-ngx/paperless-ngx/main/docker/compose/.env

The compose file starts five services: a Valkey broker, PostgreSQL 18, Gotenberg, Tika and the Paperless webserver on port 8000. Documents and data live in Docker volumes, while two folders next to the compose file are mounted into the container: ./consume for incoming files and ./export for backups.

If you want the archive on a specific disk, edit the volumes lines in docker-compose.yml. The media volume holds stored documents and the data volume holds application data. Changing ./consume only moves the import inbox, not the archive. Keep PostgreSQL data on a supported local filesystem, and check permissions and mount availability before changing storage.

Step 3: Set the secret key, time zone and OCR languages

Open docker-compose.env in a text editor. Since version 3.0, PAPERLESS_SECRET_KEY is required and Paperless refuses to start without it. Generate one:

python3 -c "import secrets; print(secrets.token_urlsafe(64))"

Then edit these lines in docker-compose.env, removing the # at the start of each one you use:

PAPERLESS_SECRET_KEY=paste-your-generated-key-here
PAPERLESS_TIME_ZONE=Asia/Kolkata
PAPERLESS_OCR_LANGUAGE=eng+hin
PAPERLESS_OCR_LANGUAGES=hin
USERMAP_UID=1000
USERMAP_GID=1000

What these do:

  • PAPERLESS_TIME_ZONE defaults to UTC. Setting it to Asia/Kolkata keeps added and created dates in IST.
  • PAPERLESS_OCR_LANGUAGE is the language OCR uses. Combine languages with +, such as eng+hin, and Tesseract uses whichever matches best.
  • PAPERLESS_OCR_LANGUAGES installs extra languages. The container only includes English, German, Italian, Spanish and French, so Hindi and other Indian languages must be listed here, separated by spaces. Common codes are hin, mar, tam, tel, kan, mal, ben and guj.
  • USERMAP_UID and USERMAP_GID should match your user on the host so you can write to the consume folder. Check yours with id -u and id -g. If both are 1000, you can leave these commented out.

Only add the languages you actually need. Each extra language slows OCR, and mixing too many lowers accuracy. If you will expose Paperless on a domain through a reverse proxy, also set PAPERLESS_URL to that address.

Step 4: Start Paperless and create your admin account

Pull the images and start the stack:

docker compose pull
docker compose up -d

The first start takes a few minutes while the database initialises and the extra OCR languages install. Watch progress with:

docker compose logs -f webserver

Open http://SERVER-IP:8000. On the first visit, Paperless asks you to create a superuser. Superusers can see every document, so the documentation suggests creating a separate everyday account later, or downgrading the superuser once setup is done. Turn on two-factor authentication for the account from your profile settings.

Paperless-ngx dashboard with saved views of recent documents and an upload area
The dashboard combines document views and an upload area. Image: Paperless-ngx

Step 5: Add your first documents

Paperless offers several ways in, and most homes end up using three of them.

Browser upload. Drag files anywhere onto the web app or use the upload button on the dashboard. Good for getting started and for one-off PDFs.

The consume folder. Anything placed in ~/paperless/consume is imported automatically and then removed from that folder, because Paperless stores its own copy. Treat it as an inbox, never as storage. Share this folder over Samba and point your scanner’s scan-to-folder feature at it, and paper goes from scanner to searchable archive with no extra steps.

Email. Under Settings > Mail, add your email account, then create mail rules that decide which messages to process: by folder, sender, subject or attachment type. A rule that picks up PDF attachments from your electricity, broadband and mobile providers takes care of monthly bills automatically. For Gmail, use the supported OAuth or app-password method for your account, rather than entering your main account password.

Paperless-ngx mail rule settings with folder, filters, attachment type and action options
Mail rules select which messages and attachments to import. Image: Paperless-ngx

Two consume-folder settings are worth knowing. PAPERLESS_CONSUMER_RECURSIVE=true lets Paperless pick up files in subfolders, and PAPERLESS_CONSUMER_SUBDIRS_AS_TAGS=true turns those subfolder names into tags, so dropping a file into consume/insurance tags it as insurance.

Step 6: Build a filing system that runs itself

Paperless organises documents with four kinds of metadata:

  • Correspondents: who the document is from, such as your bank, insurer or employer.
  • Document types: what it is, such as invoice, policy, payslip or tax return.
  • Tags: free-form labels such as tax-2026, house or car. A document can have many.
  • Storage paths: optional rules for how files are named and arranged on disk.

Each of these can match new documents automatically. When you create a tag or correspondent, pick a matching algorithm: Any, All, Exact, Regular expression, Fuzzy match or Auto. Auto is the default and learns from the documents you have already tagged, so it gets better as you correct its guesses.

Paperless-ngx create tag dialog with name, colour, inbox tag option and matching algorithm
An inbox tag marks newly imported documents for review. Image: Paperless-ngx

A practical starting set for a household:

  • Correspondents for each bank, insurer, employer, landlord and utility provider.
  • Document types for Invoice, Receipt, Policy, Payslip, Tax and Statement.
  • A year tag, such as tax-2026. Assign it after checking the document’s reporting period; a printed date alone may not identify the right tax year.
  • An inbox tag, marked as an inbox tag, so every new document gets it until you have reviewed it.

That inbox tag is the core of the recommended workflow in the official docs. New documents arrive with it, you check the suggested title, date and tags once, remove the inbox tag, and you are done.

Paperless-ngx document detail page with title, date, correspondent, document type and tags beside the PDF preview
Check the document’s suggested metadata beside the scan. Image: Paperless-ngx

Use workflows for anything rules cannot do

Workflows combine triggers and actions. A trigger can be a document being consumed, added or updated, or a schedule. Actions can assign tags, owners, permissions and custom fields, send an email or call a webhook. For example, a workflow can add the tag “warranty” and assign it to the person who scanned it whenever a file arrives from a particular folder.

Paperless-ngx workflow editor with a trigger and assignment actions
Workflows apply actions when their configured conditions match. Image: Paperless-ngx

For paper originals you must keep, turn on archive serial numbers (ASN). Write the ASN on the physical document or use a barcode sticker, and Paperless tells you exactly which box or folder holds the original.

Step 7: Search your archive

The search bar searches titles, metadata and the full OCR text of every document. Version 3 moved full-text search to a new engine, and the advanced search supports quoted phrases, wildcards, and filters on fields such as dates, tags and correspondents.

Paperless-ngx full-text search results with highlighted matches from document content
Full-text search finds words inside OCR-processed documents. Image: Paperless-ngx

Save searches you use often, such as “all tax documents this financial year”, as saved views, and pin them to the dashboard.

Optional: turn on the local AI features

Paperless-ngx 3.0 added optional AI features: AI suggestions for titles, dates, tags, correspondents and document types, similar-document retrieval, and a document chat that answers questions across your archive. They are off by default and never replace the normal matching rules.

The documentation warns that these features send document content to whichever AI backend you configure. For private documents, use a local model with Ollama. If you do not have Ollama yet, our guide to running AI models locally with Ollama covers the install. Then add these lines to docker-compose.env:

PAPERLESS_AI_ENABLED=true
PAPERLESS_AI_LLM_BACKEND=ollama
PAPERLESS_AI_LLM_MODEL=llama3.1
PAPERLESS_AI_LLM_ENDPOINT=http://192.168.1.50:11434
PAPERLESS_AI_LLM_EMBEDDING_BACKEND=ollama

Replace the IP with your Ollama machine’s address, and pull the chat model and the default embedding model, embeddinggemma, in Ollama first. The embedding backend enables the LLM index, which document chat and similar-document search rely on. Local models can be slow, so the default request timeout of 120 seconds and context size of 8192 can be raised if needed. Settings saved under Settings > Application Configuration in the web app override these environment variables.

Once enabled, a workflow action called Apply AI Suggestions can fill in titles and metadata automatically when new documents arrive.

Step 8: Back up properly

Your archive is only as good as its backup, and the original paper may be gone. Paperless includes a document exporter that writes all documents, thumbnails and a manifest.json with every tag, correspondent and setting into the export folder:

cd ~/paperless
docker compose exec -T webserver document_exporter ../export

The exporter is incremental. If the export folder already holds a previous export, it only writes new and changed files, so running it nightly is cheap. Schedule it with cron:

crontab -e
0 2 * * * cd /home/YOUR-USER/paperless && docker compose exec -T webserver document_exporter ../export

Then copy the export folder to another disk and off-site. Keep three things in mind:

  • An export can only be imported into the same version of Paperless-ngx. Note the version alongside each backup.
  • The export does not include API tokens. Regenerate them after a restore.
  • To restore, put the export in the export folder of a fresh install and run docker compose exec -T webserver document_importer ../export.

The Docker volumes, which with the default project name are paperless_data, paperless_media and paperless_pgdata, are the other thing to protect if you back up volumes directly.

Graphic of backing up Paperless-ngx with the document exporter. The exporter writes all documents, thumbnails and a manifest.json with every tag, correspondent and setting into the export folder. The exporter is incremental: if the export folder already holds a previous export, it only writes new and changed files, so a nightly cron job is cheap. Then copy the export folder to another disk and off-site. Keep three things in mind: an export can only be imported into the same version of Paperless-ngx, so note the version alongside each backup; the export does not include API tokens, so regenerate them after a restore; to restore, put the export in the export folder of a fresh install and run document_importer. The Docker volumes, which with the default project name are paperless_data, paperless_media and paperless_pgdata, are the other thing to protect if you back up volumes directly
Image: Techzei

Updating Paperless-ngx

The official compose files use the latest tag. To update:

cd ~/paperless
docker compose down
docker compose pull
docker compose up -d

Run an export before any update, and read the release notes before major versions. Version 3.0 introduced the required secret key and changed duplicate handling, which caught people who updated blindly.

Running Paperless-ngx on a Raspberry Pi

Paperless runs on a Pi, but OCR is slow. The official docs suggest:

  • Use SQLite instead of PostgreSQL to save resources.
  • Reduce OCR concurrency before limiting page coverage. PAPERLESS_OCR_PAGES=1 skips OCR after the first page, which means later scanned pages will not become searchable.
  • Set PAPERLESS_WEBSERVER_WORKERS=1 to save memory.
  • Lower PAPERLESS_TASK_WORKERS and PAPERLESS_THREADS_PER_WORKER so imports do not freeze other services.
  • Let your scanner do OCR before sending files, if it can.

Troubleshooting

Paperless will not start after an update. Check the logs with docker compose logs webserver. The most common cause on version 3 is a missing PAPERLESS_SECRET_KEY.

Files in the consume folder are ignored. Check permissions first. The container user must be able to read and delete files there, so set USERMAP_UID and USERMAP_GID to match your host user. On NFS shares, which do not support file change notifications, set PAPERLESS_CONSUMER_POLLING_INTERVAL.

Hindi or regional text comes out as gibberish. The language must be both installed with PAPERLESS_OCR_LANGUAGES and selected with PAPERLESS_OCR_LANGUAGE. Restart with docker compose up -d after changing either. Low-resolution phone photos also hurt accuracy, so scan at 300 dpi where possible.

The same bill appears twice. Since version 3, Paperless keeps duplicates by default and shows a Duplicates tab. Set PAPERLESS_CONSUMER_DELETE_DUPLICATES=true to reject them at import, as older versions did.

Mail rules do not pick anything up. Confirm the folder name, which can differ between providers, and check the maximum age setting. Gmail authentication depends on account settings and the supported mail connection method; an app password requires two-step verification and is not available on every account.

AI suggestions time out. Increase PAPERLESS_AI_LLM_REQUEST_TIMEOUT, use a smaller model, or run Ollama on a machine with a GPU.

FAQ

Is Paperless-ngx free?

Yes. Paperless-ngx is free, open-source software licensed under GPL-3.0. You only pay for the hardware it runs on and any optional cloud AI service you choose to connect.

Can Paperless-ngx read Hindi and other Indian languages?

Yes. It uses Tesseract for OCR, which supports Hindi, Marathi, Tamil, Telugu, Kannada, Malayalam, Bengali, Gujarati and more. Install the languages with PAPERLESS_OCR_LANGUAGES and select them with PAPERLESS_OCR_LANGUAGE, for example eng+hin.

Does Paperless-ngx delete my original files?

It removes files from the consume folder after importing them, but it keeps the original file inside its own storage, plus an archived PDF/A copy with searchable text. You can always download the original.

Should I use SQLite or PostgreSQL?

The documentation recommends PostgreSQL for new installs. SQLite uses fewer resources and is a reasonable choice on a Raspberry Pi or for a small archive.

Can I use Paperless-ngx from my phone?

The web interface works in a mobile browser, and the project wiki lists community mobile apps. For scanning, a phone app that saves PDFs to a shared folder or emails them to an address covered by a mail rule works well.

Is it safe to store Aadhaar and PAN copies in Paperless-ngx?

Self-hosting gives you control of storage, but it does not automatically make identity documents safer. Restrict access, use strong authentication and encrypted backups, and remember that server administrators can read document files. Keep Paperless private to your LAN or VPN.

Do the AI features send my documents to the cloud?

Only if you configure a cloud backend. With Ollama running on your own network, document content stays local. The AI features are off by default.

About the author