The documentation here is for an unreleased version of Recyclarr.
Visit the documentation site for the Current Version instead.Security
A persistent server accepts requests from any client that can reach its ports. The server API key and the web UI sign-in decide which requests it acts on, and your network setup decides which clients can reach it.
Server API Key
Every request to the server's API (any path under /api) must include the server API key. This
keeps other programs on your network, or other users on your machine, from starting syncs or
deleting custom formats in your Sonarr and Radarr instances. Browsers sign in instead,
and the requests that sign them in need no key. The API reference pages need no
key. Health probes and metrics need no key either, but they are on the separate
management port, not the API port.
Setting the Key
The server reads its key from one of two environment variables, never from settings.yml:
RECYCLARR_API_KEYholds the key itself.RECYCLARR_API_KEY_FILEholds the path of a file that contains the key, such as a Docker Compose secret or a Kubernetes Secret volume.
Set only one of them. The server logs a fatal error and exits with a non-zero exit code when neither
is set, when both are set, when it cannot read the key file, or when the key is shorter than 32
characters. This applies to recyclarr serve, the Docker image, and any
other way you run a persistent server.
Use a long random value, for example:
openssl rand -hex 32
The server reads the key file again on every request, so you can rotate the key by replacing the file's contents without a restart. If the file later becomes unreadable or holds a key that is too short, the server rejects every request and logs the cause.
Sending the Key
-
The CLI sends the key from
server.api_keyincli.yml, or fromRECYCLARR_API_KEYorRECYCLARR_API_KEY_FILEwhen either is set. Inside the Docker container, the CLI reads the same variables as the server, sodocker execcommands need no extra setup. -
Other HTTP clients send the key as a bearer token in the
Authorizationheader:curl -H "Authorization: Bearer $RECYCLARR_API_KEY" http://localhost:7982/api/v1/sync/jobs
When the key is missing or wrong, the server responds with 401 Unauthorized, a
WWW-Authenticate: Bearer header, and a Problem Details body. The CLI shows this message:
The Recyclarr server rejected the request: missing or wrong API key. Set server.api_key in cli.yml, or the RECYCLARR_API_KEY or RECYCLARR_API_KEY_FILE environment variable, to the key the server uses.
Web UI Sign-In
A persistent server can let people sign in to the web UI with a username and password that you set in environment variables. Only browsers use this sign-in. The CLI, scripts, and schedulers keep sending the API key, and the sign-in page does not accept the API key.
If you have not set a username and password, the server still starts, but nobody can sign in. An ephemeral server offers no sign-in.
Sessions
When you sign in, the server creates a session and stores it in server.db in the
state directory. The browser keeps only a cookie named recyclarr_session, which page
scripts cannot read. Sessions stay valid when the server restarts.
A session ends when one of these happens:
- You sign out.
- The browser goes unused for the session lifetime.
- The server starts with a different username or password, or with neither set. This signs out every browser.
- You delete
server.db.
Failed Sign-Ins
The server counts failed sign-ins from all clients together. After 10 failures within one minute, it
refuses every sign-in attempt, including ones with the right password, until the oldest of those
failures is a minute old. The API responds with 429 Too Many Requests and a Retry-After header
that gives the seconds to wait. The server logs each failure as a warning with the username that was
tried.
Because the limit applies to everyone, anyone who can reach the server can keep you from signing in by failing over and over. Limit which clients can reach the API port; see Network Security.
Reverse Proxies
Recyclarr ignores identity headers that a reverse proxy sets, such as Remote-User. Any client that
reaches the server without going through the proxy could set those headers itself. If a forward-auth
proxy protects the server, people still sign in to the web UI with the Recyclarr username and
password.
Network Security
The server serves plain HTTP and has no TLS settings. The API key, the web UI password, and the
session cookie travel unencrypted between a client and the server, and the
management port needs no key at all. Decide which clients can reach each port, and add
TLS where traffic crosses a network you do not trust. The server does not mark the session cookie
Secure, so a browser sends it over plain HTTP too.
- TLS: Terminate TLS in front of the server with a reverse proxy, a tunnel, a Kubernetes Ingress, or a service mesh. Plain HTTP between that proxy and the server is fine on a network you trust.
- API port: Publish it only to the clients that need it. CLI commands run with
docker execreach the server inside the container, so they need no published port at all. - Management port: It listens on the same address as the API port. In Docker, publish it only if
something outside the container scrapes metrics or probes health. In Kubernetes, probes and
Prometheus reach it on the pod IP, so restrict it with a
NetworkPolicy.
To publish the API port only on the Docker host itself, bind it to the loopback address:
services:
recyclarr:
ports:
- 127.0.0.1:7982:7982
This NetworkPolicy lets only pods in a monitoring namespace reach the management port, while the
API port stays open to the rest of the cluster. Health probes still work, because a NetworkPolicy
always allows traffic from the pod's own node, where the kubelet runs. Adjust the selectors to your
cluster:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: recyclarr
spec:
podSelector:
matchLabels:
app.kubernetes.io/name: recyclarr
policyTypes:
- Ingress
ingress:
- ports:
- port: 7982
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: monitoring
ports:
- port: 7983