crawl4ai icon indicating copy to clipboard operation
crawl4ai copied to clipboard

[Bug]: Docker v0.9.0,cant using dashboard,ERR_EMPTY_RESPONSE

Open AlexTuring32 opened this issue 5 months ago • 5 comments

crawl4ai version

0.9.0

Expected Behavior

just wanna use crawl4ai

Current Behavior

windows 11 pro/wsl2/docker desktop/ docker pull unclecode/crawl4ai:latest docker run -d -p 11235:11235 --name crawl4ai --shm-size=1g unclecode/crawl4ai:latest http://localhost:11235/dashboard return:ERR_EMPTY_RESPONSE

i try to change port docker run -d -p 5001:11235 --name crawl4ai --shm-size=3g unclecode/crawl4ai:latest but still cant use

and than. i try to add -e CRAWL4AI_API_TOKEN="xxxxxxxxxx" docker run -d -p 5001:11235 --name crawl4ai -e CRAWL4AI_API_TOKEN="xxxxxxxxx" --shm-size=3g unclecode/crawl4ai:latest it works~ return: "detail": "Authentication required"

Is this reproducible?

Yes

Inputs Causing the Bug


Steps to Reproduce


Code snippets


OS

win 11 pro

Python version

3.14

Browser

chrome

Browser version

No response

Error logs & Screenshots (if applicable)

PS C:\WINDOWS\system32> docker run -d -p 5001:11235 --name crawl4ai -e CRAWL4AI_API_TOKEN="xxxxxxxxxx" --shm-size=3g unclecode/crawl4ai:latest 034960e7d7440d4fb3ad37782eadd90d37200c183f6341c13a43b3c94d2163c6 PS C:\WINDOWS\system32> docker logs crawl4ai entrypoint: no REDIS_PASSWORD provided; generated an ephemeral one. 2026-06-25 07:29:52,449 CRIT could not write pidfile /app/supervisord.pid 2026-06-25 07:29:53,452 INFO spawned: 'redis' with pid 8 2026-06-25 07:29:53,454 INFO spawned: 'gunicorn' with pid 9 8:C 25 Jun 2026 07:29:53.462 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 8:C 25 Jun 2026 07:29:53.462 * Redis version=8.8.0, bits=64, commit=00000000, modified=1, pid=8, just started 8:C 25 Jun 2026 07:29:53.462 * Configuration loaded 8:M 25 Jun 2026 07:29:53.463 * monotonic clock: POSIX clock_gettime 8:M 25 Jun 2026 07:29:53.463 * Running mode=standalone, port=6379. 8:M 25 Jun 2026 07:29:53.464 * Server initialized 8:M 25 Jun 2026 07:29:53.464 * Ready to accept connections tcp [2026-06-25 07:29:53 +0000] [9] [INFO] Starting gunicorn 26.0.0 [2026-06-25 07:29:53 +0000] [9] [INFO] Listening at: http://[::]:11235 (9) [2026-06-25 07:29:53 +0000] [9] [INFO] Using worker: uvicorn.workers.UvicornWorker [2026-06-25 07:29:53 +0000] [15] [INFO] Booting worker with pid: 15 [2026-06-25 07:29:53 +0000] [9] [INFO] Control socket listening at /home/appuser/.gunicorn/gunicorn.ctl 2026-06-25 07:29:54,898 INFO success: redis entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) 2026-06-25 07:29:54,898 INFO success: gunicorn entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) No SECRET_KEY set. Auto-generated an ephemeral key (changes on restart, invalidating issued tokens). Set SECRET_KEY for any real deployment. /app/job.py:49: UserWarning: Field name "schema" in "LlmJobPayload" shadows an attribute in parent "BaseModel" class LlmJobPayload(BaseModel): /app/server.py:1012: FastAPIDeprecationWarning: regex has been deprecated, please use pattern instead context_type: str = Query("all", regex="^(code|doc|all)$"), MCP server running on 127.0.0.1:11235 [2026-06-25 07:29:55 +0000] [15] [INFO] Started server process [15] [2026-06-25 07:29:55 +0000] [15] [INFO] Waiting for application startup. 2026-06-25 07:29:55,595 - server - INFO - Auth gate active (credential configured). 2026-06-25 07:29:55,601 - crawl4ai.egress - INFO - egress pinning proxy listening on http://127.0.0.1:37907 2026-06-25 07:29:55,602 - crawl4ai.workqueue - INFO - work queue started (maxsize=1000, workers=4, per_principal=unlimited) 2026-06-25 07:29:55,604 - monitor - INFO - Started persistence worker 2026-06-25 07:29:55,633 - crawler_pool - INFO - 🔥 Creating permanent default browser [INIT].... → Crawl4AI 0.9.0 [2026-06-25 07:29:56 +0000] [15] [INFO] Application startup complete. PS C:\WINDOWS\system32> curl http://localhost:5001/health

安全警告: 脚本执行风险 Invoke-WebRequest 可解析网页内容。解析网页时,可能会运行网页中的脚本代码。 建议的操作: 使用 -UseBasicParsing 开关来避免执行脚本代码。

  是否要继续?

[Y] 是(Y) [A] 全是(A) [N] 否(N) [L] 全否(L) [S] 暂停(S) [?] 帮助 (默认值为“N”): Y

StatusCode : 200 StatusDescription : OK Content : {"status":"ok","timestamp":1782372691.02042,"version":"0.9.0"} RawContent : HTTP/1.1 200 OK x-content-type-options: nosniff x-frame-options: DENY referrer-policy: no-referrer cross-origin-opener-policy: same-origin cross-origin-resource-policy: same-origin content-secur... Forms : {} Headers : {[x-content-type-options, nosniff], [x-frame-options, DENY], [referrer-policy, no-referrer], [cross -origin-opener-policy, same-origin]...} Images : {} InputFields : {} Links : {} ParsedHtml : mshtml.HTMLDocumentClass RawContentLength : 62

PS C:\WINDOWS\system32> docker run -d -p 5001:11235 --name crawl4ai --shm-size=3g unclecode/crawl4ai:latest d0d52c6f38758152f7c27b4b3e0ce024fc8073dc2054436dc5ae7e2cd84a2742 PS C:\WINDOWS\system32> curl http://localhost:5001/health curl : 基础连接已经关闭: 连接被意外关闭。 所在位置 行:1 字符: 1

  • curl http://localhost:5001/health
  •   + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest],WebExce
      ption
      + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
    
    

PS C:\WINDOWS\system32> docker logs crawl4ai entrypoint: no REDIS_PASSWORD provided; generated an ephemeral one. entrypoint: no CRAWL4AI_API_TOKEN set; binding loopback only (127.0.0.1:11235). 2026-06-25 07:33:33,480 CRIT could not write pidfile /app/supervisord.pid 2026-06-25 07:33:34,484 INFO spawned: 'redis' with pid 8 2026-06-25 07:33:34,486 INFO spawned: 'gunicorn' with pid 9 8:C 25 Jun 2026 07:33:34.494 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 8:C 25 Jun 2026 07:33:34.494 * Redis version=8.8.0, bits=64, commit=00000000, modified=1, pid=8, just started 8:C 25 Jun 2026 07:33:34.494 * Configuration loaded 8:M 25 Jun 2026 07:33:34.494 * monotonic clock: POSIX clock_gettime 8:M 25 Jun 2026 07:33:34.494 * Running mode=standalone, port=6379. 8:M 25 Jun 2026 07:33:34.495 * Server initialized 8:M 25 Jun 2026 07:33:34.495 * Ready to accept connections tcp [2026-06-25 07:33:34 +0000] [9] [INFO] Starting gunicorn 26.0.0 [2026-06-25 07:33:34 +0000] [9] [INFO] Listening at: http://127.0.0.1:11235 (9) [2026-06-25 07:33:34 +0000] [9] [INFO] Using worker: uvicorn.workers.UvicornWorker [2026-06-25 07:33:34 +0000] [15] [INFO] Booting worker with pid: 15 [2026-06-25 07:33:34 +0000] [9] [INFO] Control socket listening at /home/appuser/.gunicorn/gunicorn.ctl 2026-06-25 07:33:35,989 INFO success: redis entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) 2026-06-25 07:33:35,989 INFO success: gunicorn entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) No SECRET_KEY set. Auto-generated an ephemeral key (changes on restart, invalidating issued tokens). Set SECRET_KEY for any real deployment. /app/job.py:49: UserWarning: Field name "schema" in "LlmJobPayload" shadows an attribute in parent "BaseModel" class LlmJobPayload(BaseModel): 2026-06-25 07:33:36,565 - crawl4ai.security - WARNING - CRAWL4AI_API_TOKEN is not set. All API endpoints are unauthenticated. Set CRAWL4AI_API_TOKEN environment variable to enable authentication. /app/server.py:1012: FastAPIDeprecationWarning: regex has been deprecated, please use pattern instead context_type: str = Query("all", regex="^(code|doc|all)$"), MCP server running on 127.0.0.1:11235 [2026-06-25 07:33:36 +0000] [15] [INFO] Started server process [15] [2026-06-25 07:33:36 +0000] [15] [INFO] Waiting for application startup. 2026-06-25 07:33:36,605 - server - WARNING - No CRAWL4AI_API_TOKEN set; generated an ephemeral token for this loopback session: CRAWL4AI_API_TOKEN=5b0ef31beb97e31a8a2804371574a68c187ac09f1c82b5863ccd182cc76446f1 2026-06-25 07:33:36,611 - crawl4ai.egress - INFO - egress pinning proxy listening on http://127.0.0.1:33393 2026-06-25 07:33:36,612 - crawl4ai.workqueue - INFO - work queue started (maxsize=1000, workers=4, per_principal=unlimited) 2026-06-25 07:33:36,615 - monitor - INFO - Started persistence worker 2026-06-25 07:33:36,644 - crawler_pool - INFO - 🔥 Creating permanent default browser [INIT].... → Crawl4AI 0.9.0 [2026-06-25 07:33:37 +0000] [15] [INFO] Application startup complete.

AlexTuring32 avatar Jun 25 '26 07:06 AlexTuring32

I had the same issue. Without a CRAWL4AI_API_TOKEN crawl4ai only listen on localhost inside the docker, which in fact you can't access. To use the dashboard and playground you need to set Authorization: Bearer xxxxxxxxx header, which is not possible in a browser. Dashboard and playground don't accept ?token=xxxxxxxxx URL param. I think dashboard and playground are broken in Docker + 0.9.0.

ssh-manu avatar Jun 25 '26 09:06 ssh-manu

Dug into this on current develop. There are two separate things in the report; the second is the real UI bug.

1. No token set -> ERR_EMPTY_RESPONSE. This is the intended 0.9.0 secure-by-default behavior, not a UI bug. With no CRAWL4AI_API_TOKEN (and JWT off), _resolve_auth() / the entrypoint bind the server to loopback only, so the port isn't reachable from outside the container and the browser gets an empty response. Setting a token (or enabling JWT) makes it bind normally.

2. Token set -> {"detail":"Authentication required"} when opening /dashboard or /playground. This is the actual bug, and it's more fundamental than the UI just "forgetting" a header.

AuthGateMiddleware (deploy/docker/auth_gate.py) is the outermost ASGI gate and covers every route and static mount. Its public allowlist is only:

# deploy/docker/server.py
app.add_middleware(
    AuthGateMiddleware,
    token_provider=_current_api_token,
    public_paths={HEALTH_PATH, "/token"},
)

So /dashboard, /playground, /static/* and /monitor/* all require a credential. Two consequences:

  • For HTTP, the gate only reads the token from the Authorization: Bearer header. The ?token= query-param fallback is gated to WebSocket connections only (auth_gate.py:94-99). A browser can't attach an Authorization header to a top-level navigation, so just opening http://host:11235/dashboard in the address bar is rejected with 401 before any HTML is served. The page can never bootstrap.
  • Even if it did load, the static pages send no credential on their calls: static/playground/index.html and static/monitor/index.html issue plain fetch() / new WebSocket() with no Authorization header and no ?token=, so every data call would 401 / close 4401.

(_UI_PREFIXES in server.py is only a CSP exemption for the inline-script pages, not an auth exemption, so it doesn't help here.)

Suggested fix (keeps the API fail-closed):

  1. Let the static UI shell load without a credential, since it serves no data, only HTML/CSS/JS. Either add the UI mounts to public_paths (e.g. /playground, /dashboard, /static) or mount them ahead of the gate.
  2. Give the UI a way to acquire and carry a token: a small token field (or a login that posts to the existing /token endpoint), persisted in sessionStorage, then attach Authorization: Bearer <token> to every fetch() and append ?token=<token> to the monitor WebSocket URL (the gate already accepts ?token= on WS, and monitor_routes.py references it).

That keeps every data/API route gated while letting the dashboard and playground actually authenticate from a browser.

Happy to open a PR along these lines if that direction looks right. Wanted to confirm the approach first since it touches the new auth boundary and I didn't want to second-guess the secure-by-default design.

sevenmoonlightsteps avatar Jun 25 '26 14:06 sevenmoonlightsteps

Root cause: AuthGateMiddleware (deploy/docker/auth_gate.py) is the outermost ASGI gate and covers every route. Its public_paths allowlist only includes /health and /token — so /dashboard, /playground, and /static/* all require a credential.

Two problems make the UI unreachable:

  1. HTTP token extraction only accepts Authorization: Bearer header (auth_gate.py:87-93). The ?token= query param fallback is WebSocket-only (auth_gate.py:95-99). Browsers can't attach custom headers to top-level navigation, so opening http://host:11235/dashboard in the address bar is rejected with 401 before any HTML is served.
  2. The static UI pages send no credentials on their API calls — all fetch() calls in playground/index.html and monitor/index.html have no Authorization header.

Fix (in progress): Let the static UI shell (HTML/CSS/JS) load without credentials via public_prefixes on the middleware — it serves no data. Then add a token input bar to both UIs that stores the token in sessionStorage and attaches Authorization: Bearer <token> to all fetch() and ?token= to WebSocket calls. All data/API routes stay fail-closed.

ntohidi avatar Jun 27 '26 16:06 ntohidi

I'm still experiencing this issue on latest

Mubelotix avatar Aug 23 '26 12:08 Mubelotix

@Mubelotix Just re-verified on unclecode/crawl4ai:latest (same digest as 0.9.2) - the #2039 fix works there, so I suspect you're hitting the other half of this issue:

No CRAWL4AI_API_TOKEN set -> ERR_EMPTY_RESPONSE. Intended secure-by-default: without a token the entrypoint binds loopback inside the container (docker logs shows binding loopback only (127.0.0.1:11235)), so the published port is unreachable. Fix:

docker run -d -p 11235:11235 --shm-size=1g \
  -e CRAWL4AI_API_TOKEN=your-secret-token \
  unclecode/crawl4ai:latest

Then open http://localhost:11235/dashboard and paste the token into the UI's token bar. I confirmed this works end-to-end on latest: dashboard and playground load, authenticated calls succeed, unauthenticated ones still 401.

If you do have a token set and the dashboard still won't load, that's a new regression - please share your exact docker run command and the first ~20 lines of docker logs.

Note for maintainers: the no-token path could use a friendlier surface - the loopback warning only lives in docker logs, so from the browser the failure looks like a broken container. Even a plain "no token configured, see docs" page on the public port would prevent reports like this.

sevenmoonlightsteps avatar Aug 23 '26 16:08 sevenmoonlightsteps