From 76d221a8fc4243713463459cbb08c7126e34deda Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 20 Jan 2026 12:16:05 +0000 Subject: [PATCH 1/2] docs: add documentation for wrangler login in Docker containers Co-Authored-By: pbacondarwin@cloudflare.com --- .../docs/workers/wrangler/commands.mdx | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/content/docs/workers/wrangler/commands.mdx b/src/content/docs/workers/wrangler/commands.mdx index 4ce9bf902d6fe93..2c9c82a7b21d491 100644 --- a/src/content/docs/workers/wrangler/commands.mdx +++ b/src/content/docs/workers/wrangler/commands.mdx @@ -669,6 +669,38 @@ Leave the login flow active. Open a second terminal session. In that second term curl ``` +### Use `wrangler login` in a Docker container + +When running Wrangler inside a Docker container, the OAuth callback server cannot listen on `localhost` because `localhost` inside the container is not accessible from your host machine's browser. + +To work around this, use the `--callback-host` option to make Wrangler listen on all network interfaces: + +```sh +npx wrangler login --callback-host=0.0.0.0 +``` + +The Cloudflare OAuth provider only accepts `localhost:8976` as the redirect URI, so the login URL will always redirect to `http://localhost:8976/oauth/callback` regardless of your `--callback-host` setting. You must configure your Docker container to map port `8976` on your host machine to port `8976` inside the container. + +When starting your Docker container, include the port mapping: + +```sh +docker run -p 8976:8976 +``` + +With this configuration, when the browser redirects to `localhost:8976`, the request will be forwarded to Wrangler running inside the container on `0.0.0.0:8976`. + +If you need to use a different port inside the container, use both `--callback-host` and `--callback-port`, and adjust your Docker port mapping accordingly: + +```sh +# Inside the container +npx wrangler login --callback-host=0.0.0.0 --callback-port=9000 + +# Docker run command +docker run -p 8976:9000 +``` + +This maps `localhost:8976` on your host to port `9000` inside the container where Wrangler is listening. + --- ## `logout` From 08de0a513ae3f99dadb112b0f5f40666c732076c Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 20 Jan 2026 14:42:56 +0000 Subject: [PATCH 2/2] docs: update container login section per emily-shen's suggestion Co-Authored-By: pbacondarwin@cloudflare.com --- .../docs/workers/wrangler/commands.mdx | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/content/docs/workers/wrangler/commands.mdx b/src/content/docs/workers/wrangler/commands.mdx index 2c9c82a7b21d491..df2cce705db7449 100644 --- a/src/content/docs/workers/wrangler/commands.mdx +++ b/src/content/docs/workers/wrangler/commands.mdx @@ -669,38 +669,36 @@ Leave the login flow active. Open a second terminal session. In that second term curl ``` -### Use `wrangler login` in a Docker container +### Use `wrangler login` in a container -When running Wrangler inside a Docker container, the OAuth callback server cannot listen on `localhost` because `localhost` inside the container is not accessible from your host machine's browser. +The Cloudflare OAuth provider will always redirect to a callback server at `localhost:8976`. If you are running Wrangler inside a container, this server might not be accessible from your host machine's browser - even after authorizing the connection, your login command will hang. -To work around this, use the `--callback-host` option to make Wrangler listen on all network interfaces: +You must configure your container to map port `8976` on your host machine to the Wrangler OAuth callback server's port (`8976` by default). + +For example, if you are running Wrangler in a Docker container: ```sh -npx wrangler login --callback-host=0.0.0.0 +docker run -p 8976:8976 ``` -The Cloudflare OAuth provider only accepts `localhost:8976` as the redirect URI, so the login URL will always redirect to `http://localhost:8976/oauth/callback` regardless of your `--callback-host` setting. You must configure your Docker container to map port `8976` on your host machine to port `8976` inside the container. - -When starting your Docker container, include the port mapping: +And when you run `npx wrangler login` inside your container, set the callback host to listen on all network interfaces: ```sh -docker run -p 8976:8976 +npx wrangler login --callback-host=0.0.0.0 ``` -With this configuration, when the browser redirects to `localhost:8976`, the request will be forwarded to Wrangler running inside the container on `0.0.0.0:8976`. +Now when the browser redirects to `localhost:8976`, the request will be forwarded to Wrangler running inside the container on `0.0.0.0:8976`. -If you need to use a different port inside the container, use both `--callback-host` and `--callback-port`, and adjust your Docker port mapping accordingly: +If you need to use a different port inside the container, use `--callback-port` as well and adjust your port mapping accordingly, for example: ```sh +# When starting your container +docker run -p 8976:9000 + # Inside the container npx wrangler login --callback-host=0.0.0.0 --callback-port=9000 - -# Docker run command -docker run -p 8976:9000 ``` -This maps `localhost:8976` on your host to port `9000` inside the container where Wrangler is listening. - --- ## `logout`