Freqtrade Docker Compose: many bots, one address
Freqtrade's own docker-compose.yml runs one bot and publishes its API and FreqUI on 127.0.0.1:8080. With several bots each one gets its own port, and FreqUI in the browser then talks to several addresses. That is where the CORS error comes from. This page covers what the API settings do, what breaks and why, and how to put every bot behind one address.
Where the CORS error comes from
- FreqUI is a web app that runs in your browser. Every bot serves a copy of it on its API port
- To a browser an origin is scheme, host and port.
http://localhost:8080andhttp://localhost:8081are two origins - FreqUI loaded from the first bot may only call the second bot's API if that bot lists FreqUI's origin in
api_server.CORS_origins. The Freqtrade docs call this the cross-origin case and say the setting is needed only there - FreqUI adds a hint to check the CORS configuration to every login that fails for a reason other than a wrong password, when the bot's address is not the address of the page. An unreachable bot gets the same hint, so open
<bot address>/api/v1/pingfirst. It answers{"status":"pong"}when the API is up
What the api_server settings do
| Setting | What it does |
|---|---|
enabled | turns the REST API on. FreqUI is served from the same port |
listen_ip_address | the address the API binds to. The sample config uses 127.0.0.1. In Docker it has to be 0.0.0.0, or the published port reaches nothing. Who can reach the bot is then decided by the ports line |
listen_port | the port inside the container, 8080 in the samples |
username, password | the API login. FreqUI sends them once and gets two tokens back |
jwt_secret_key | signs those tokens: an access token valid for 15 minutes and a refresh token valid for 30 days. The docs ask for a random value of 32 characters or more. Freqtrade logs a security warning when it is still a sample value. A token signed with an old key is no longer accepted, so after a change every browser logs in again |
CORS_origins | the list of origins that may call this API from a browser, such as ["http://localhost:8080"]. No trailing slash. A * entry is not allowed by the standard for requests with credentials |
ws_token | a fixed token for the message websocket at /api/v1/message/ws, for other programs such as a consumer bot in producer and consumer mode. FreqUI does not need it. It opens the same websocket with its access token, and the API accepts either |
What breaks, and why
| What you see | Cause |
|---|---|
| Login to a second bot fails with the CORS hint | CORS_origins of that bot does not hold the address in your browser bar, or holds it with a trailing slash |
| The published port answers nothing | listen_ip_address is still 127.0.0.1 inside the container |
| The API answers from the whole network | the port is published as "8080:8080". "127.0.0.1:8080:8080" keeps it on the host. The docs advise against exposing the API to the internet and name an SSH tunnel or a VPN for remote access |
| The websocket fails behind nginx | nginx needs the Upgrade and Connection headers set for websockets. Traefik and Caddy v2 support websockets out of the box |
| A second browser or device shows no bots | FreqUI keeps its bot list and the tokens in that browser's local storage |
One origin by hand
Requests to the origin the page came from are not cross-origin, so no CORS rule applies to them. A reverse proxy can give FreqUI and every bot API the same scheme, host and port. FreqUI appends /api/v1 to the address you enter for a bot, so a bot can sit under a path such as /bots/meanrev as long as the proxy strips that prefix before it passes the request on.
With Traefik, one bot serves FreqUI at the root and every further bot gets a path:
services:
traefik:
image: traefik:v3.7.17
restart: unless-stopped
command:
- --providers.docker=true
- --providers.docker.exposedbydefault=false
- --entrypoints.web.address=:8000
ports:
- "127.0.0.1:8000:8000"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
trend:
image: freqtradeorg/freqtrade:stable
restart: unless-stopped
volumes:
- ./trend/user_data:/freqtrade/user_data
command: trade --config /freqtrade/user_data/config.json --db-url sqlite:////freqtrade/user_data/tradesv3.sqlite --strategy Trend
labels:
traefik.enable: "true"
traefik.http.routers.trend.rule: "PathPrefix(`/`)"
traefik.http.routers.trend.entrypoints: web
traefik.http.routers.trend.priority: "1"
traefik.http.services.trend.loadbalancer.server.port: "8080"
meanrev:
image: freqtradeorg/freqtrade:stable
restart: unless-stopped
volumes:
- ./meanrev/user_data:/freqtrade/user_data
command: trade --config /freqtrade/user_data/config.json --db-url sqlite:////freqtrade/user_data/tradesv3.sqlite --strategy MeanRev
labels:
traefik.enable: "true"
traefik.http.routers.meanrev.rule: "PathPrefix(`/bots/meanrev/`)"
traefik.http.routers.meanrev.entrypoints: web
traefik.http.routers.meanrev.priority: "50"
traefik.http.routers.meanrev.middlewares: meanrev-strip
traefik.http.middlewares.meanrev-strip.stripprefix.prefixes: /bots/meanrev
traefik.http.services.meanrev.loadbalancer.server.port: "8080"
No bot publishes a port. Each bot's config.json carries:
"api_server": {
"enabled": true,
"listen_ip_address": "0.0.0.0",
"listen_port": 8080,
"jwt_secret_key": "32 random characters or more, per bot",
"CORS_origins": [],
"username": "trend",
"password": "a strong password, per bot"
}
Open http://localhost:8000, log in to the first bot at that address, then add the second with the API URL http://localhost:8000/bots/meanrev. CORS_origins stays empty on both.
What stays manual: every bot keeps its own login, typed into each browser. The proxy itself has no login, so keep the port on 127.0.0.1 or behind a VPN. Each further bot is one more block of labels.
How Wickfleet sets it up
Wickfleet's deploy/compose/compose.yml is the same idea with a login in front. The bots are not in the compose file. The hub creates one container per bot file in the registry and writes the route labels itself.
| Service | Job |
|---|---|
traefik | the only published port, 127.0.0.1:8000 by default. It reads container labels through a read-only Docker socket proxy |
ui | the FreqUI fork as static files, for every path outside /api, /bots/ and /hub/ |
hub | the login and the API under /hub/. Traefik asks the hub before it passes a request to the UI or to a bot |
dockerguard | sits between the hub and a second socket proxy. It lets the hub create containers only from the listed Freqtrade image, with the listed bind paths, network and user |
| Bot containers | one per bot, routed at /bots/<name>/ with the prefix stripped, to port 8080, with no published port |
The hub also writes the api_server block of every bot:
| Setting | Value the hub writes |
|---|---|
enabled, listen_ip_address, listen_port | true, 0.0.0.0, 8080 |
CORS_origins | []. Every bot is on the origin of the UI |
username | the bot's name |
password, jwt_secret_key | random, 32 bytes each, made per bot on first use and kept in the hub's state directory |
ws_token | not set |
- You log in once at the hub. For a bot request without a token, the hub hands Traefik that bot's username and password, so the browser never holds a bot password. It does hold the session tokens the bot issues
- Viewers and operators reach their own bots, a viewer only to read. Admins reach every bot. More in roles and login
- A new bot is one file in the registry, not a new compose service

Try it
git clone https://github.com/wickfleet/wickfleet.git
cd wickfleet
make quickstart
Needs Docker with Compose v2, git and make, on macOS or Linux. Everything runs on one machine, bound to 127.0.0.1, and a dry-run demo bot is waiting in the fleet. More in the install guide.
More on running a fleet
- Multiple bots on one serverWhat each bot needs of its own, by hand and from a registry
- One dashboard for every botFleet totals, compare and risk on top of FreqUI
- Lookahead bias checksWhat it is, how to find it, and the gate before a bot starts
- A strategy without PythonBlocks, a plain-words readback and the generated code
- Backtest against dry runWhy the two differ, and what a replay checks
- Dashboards comparedOpen-source ways to watch several Freqtrade bots
Wickfleet is software for running trading bots, not a recommendation to buy or sell anything. Backtests and replays describe the past, not the future. Every bot is a dry run on a simulated wallet by default.