How to Fix “CSRF Verification Failed” When Accessing Paperless-ngx
To fix the CSRF verification failed error in Paperless-ngx, check that your browser uses the correct URL, clear outdated browser cookies, and configure the PAPERLESS_URL environment variable with your actual Paperless-ngx address.
If you’re accessing it through a domain or reverse proxy, add that domain to PAPERLESS_CSRF_TRUSTED_ORIGINS.
Also, verify your HTTPS and proxy settings, then restart the Paperless-ngx containers.
Let’s explore each fixes in detail
Fix CSRF Verification Failed in Paperless-ngx

Below, I have explained every step in detail; follow the steps one by one to resolve the issue.
Step 1: Check the URL You’re Using to Access Paperless-ngx
Before changing any configuration, check the URL you’re using to access Paperless-ngx.
For example, you might access your installation through a local IP address such as http://192.168.1.100:8000, or through a custom domain such as https://paperless.example.com.
The problem can occur when the address you’re using doesn’t match the URL configured in Paperless-ngx.
For instance, if your configuration uses HTTPS but you’re opening Paperless-ngx through HTTP, the application may reject certain requests because the origin doesn’t match the expected address.
Open your browser and enter the correct Paperless-ngx URL. Make sure you’re using the same protocol, hostname, and port configured for your installation.
If you’ve recently changed your domain, reverse proxy, or SSL certificate, double-check those settings before moving to the next method.
Step 2: Clear Browser Cookies and Cached Data
Sometimes, the CSRF error isn’t caused by your Paperless-ngx configuration. Your browser may be holding onto outdated cookies or session information.
Paperless-ngx uses cookies and security tokens to verify certain requests. If these values become outdated or inconsistent, the application may reject your login attempt.
To check whether this is the problem, open Paperless-ngx in an Incognito or Private Browsing window.
In Chrome, press Ctrl + Shift + N to open an Incognito window. In Firefox, press Ctrl + Shift + P to open a Private Browsing window.
Now, enter your Paperless-ngx URL and try logging in again.
If you can access your account without receiving the error, your regular browser may have outdated cookies.
Go to your browser’s privacy settings and clear the cookies and cached site data associated with your Paperless-ngx domain. You don’t necessarily need to delete all browsing history.
Close the browser tab, reopen Paperless-ngx, and try signing in again.
Step 3: Configure the PAPERLESS_URL Environment Variable
This is one of the most important methods, particularly if you’re accessing Paperless-ngx through a custom domain or reverse proxy.
The PAPERLESS_URL environment variable tells Paperless-ngx which public URL should be used to access the application.
If this variable is missing or incorrectly configured, Django’s security checks may reject requests from your browser.
First, locate your Paperless-ngx installation directory and open the Docker Compose environment configuration file.
Depending on your installation, this could be a docker-compose.env file or an environment section inside your docker-compose.yml file.
Find the environment variables section and add the following configuration:
PAPERLESS_URL=https://paperless.example.com
Replace paperless.example.com with your actual domain.
If you’re accessing Paperless-ngx locally without a reverse proxy, use the actual address through which you access it, including the correct port where applicable.
Important: Don’t add a trailing slash to the PAPERLESS_URL value. For example, use https://paperless.example.com, not https://paperless.example.com/.
Also, don’t include a URL path in this variable. Paperless-ngx documentation explains that this setting can automatically configure related allowed-host and trusted-origin settings.
Save your changes before moving to the next step.
Step 4: Add the Correct CSRF Trusted Origins
If the previous method doesn’t fix the issue, check the PAPERLESS_CSRF_TRUSTED_ORIGINS setting.
This variable tells Paperless-ngx which website origins it should trust when processing requests that can change data, such as login submissions.
Open your Docker Compose environment file again and add the following line:
PAPERLESS_CSRF_TRUSTED_ORIGINS=https://paperless.example.com
Replace the example domain with your actual Paperless-ngx address.
If you access the application through multiple legitimate domains, you can add them as a comma-separated list.
For example:
PAPERLESS_CSRF_TRUSTED_ORIGINS=https://paperless.example.com,https://docs.example.com
Make sure every entry uses the correct protocol and hostname.
Don’t add random websites or use wildcard entries just to bypass the error. This setting is security-related, so only include origins you control and intend to use.
Save the configuration file after making the changes.
You should also remember that setting PAPERLESS_URL can configure this trusted-origin list automatically. If you manually define both variables, make sure their values are consistent.
Step 5: Check Your Reverse Proxy Configuration
Are you accessing Paperless-ngx through Nginx Proxy Manager, Nginx, Apache, Caddy, or Traefik?
If so, your reverse proxy configuration could be responsible for the CSRF error.
A reverse proxy sits between your browser and Paperless-ngx. It forwards requests to the application and can also handle HTTPS connections.
If the proxy doesn’t forward the correct information, Paperless-ngx may misunderstand the original request.
Check whether your proxy forwards the original host and protocol information correctly.
For an Nginx configuration, the relevant proxy headers commonly look like this:
proxy_set_header Host $host;
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;
These headers help the application understand the original request.
Also, check the official Paperless-ngx reverse proxy guidance for the configuration specific to your proxy software.
One important exception: If your browser’s request is being rejected with an origin value of null, check your reverse proxy’s Referrer-Policy response header. A policy of no-referrer can cause browsers to send Origin: null on certain same-origin form submissions.
In that situation, simply adding another trusted origin won’t solve the problem. The proxy must be configured to use an appropriate policy, such as same-origin, while ensuring an existing no-referrer header is actually replaced.
This is a less obvious cause documented in a Paperless-ngx troubleshooting discussion.
Step 6: Restart Your Paperless-ngx Docker Containers
After updating your environment variables, you need to restart or recreate the Paperless-ngx containers so the application can load the new configuration.
Open your terminal or command prompt and navigate to the directory containing your Docker Compose file.
Run the following command:
docker compose up -d –force-recreate
This command recreates the services using the updated configuration while running them in the background.
If your installation uses the older Docker Compose command, you may need to use:
docker-compose up -d –force-recreate
Wait for the containers to start. You can check their status by running:
docker compose ps
If everything looks good, open your browser and access Paperless-ngx again.
Try logging in and check whether the CSRF error has disappeared.
Important: Don’t delete your Docker volumes or run commands that remove persistent data. Recreating containers is not the same as deleting your document storage.
Step 7: Check Paperless-ngx Logs for the Exact Error
If you’ve tried the previous methods and still see the error, it’s time to check the application logs.
Logs can help identify exactly why Paperless-ngx is rejecting your request.
Open your terminal and run:
docker compose logs –tail=100 webserver
If your installation uses a different service name, replace webserver with the appropriate service name from your Docker Compose configuration.
Look for messages containing:
django.security.csrf
Pay particular attention to messages such as:
Origin checking failed
If the message mentions your domain, your trusted-origin configuration may be incorrect.
If it says:
Origin checking failed – null does not match any trusted origins
investigate the reverse proxy’s Referrer-Policy header as explained in Step 5.
You can also check whether the application is running correctly and whether any other configuration errors appear in the logs.
This method is particularly useful because it helps you identify the actual cause instead of repeatedly changing unrelated settings.
FAQs
1. What does CSRF verification failed mean in Paperless-ngx?
It means Paperless-ngx has rejected a request because its Cross-Site Request Forgery security check couldn’t verify that the request came from a trusted origin. Incorrect domain settings, missing trusted origins, browser cookies, or reverse proxy issues can cause this error.
2. Why does Paperless-ngx show a CSRF error when logging in?
This usually happens when the URL you’re using doesn’t match the configured PAPERLESS_URL or trusted origins. It can also happen when your browser sends an invalid security token or your reverse proxy forwards incorrect request information.
3. Can I fix the Paperless-ngx CSRF error without reinstalling Docker?
Yes. You generally don’t need to reinstall Docker or Paperless-ngx. Correcting environment variables, clearing browser cookies, and restarting the affected containers are often enough to resolve the problem.
4. Does changing PAPERLESS_URL delete my documents?
No. Changing PAPERLESS_URL doesn’t delete your stored documents. It updates the application’s public URL configuration. However, always keep a backup of your Paperless-ngx database and document storage before making major configuration changes.
5. Why does Paperless-ngx work locally but not through my domain?
This usually indicates a reverse proxy, HTTPS, or trusted-origin configuration issue. Your local address may be accepted, while your public domain isn’t included in the application’s security settings. Check PAPERLESS_URL and PAPERLESS_CSRF_TRUSTED_ORIGINS.
6. What is the difference between PAPERLESS_URL and PAPERLESS_CSRF_TRUSTED_ORIGINS?
PAPERLESS_URL defines the main public URL of your Paperless-ngx installation and can configure related security settings automatically.
PAPERLESS_CSRF_TRUSTED_ORIGINS specifically identifies the origins trusted for requests that require CSRF verification.
7. Why am I getting a 403 error in Paperless-ngx?
A 403 error means the server understood your request but refused to process it. In Paperless-ngx, this can happen when Django’s CSRF protection rejects a login or other request because its origin or security token isn’t valid.
