cloudflare / cloudflare/workers-sdk

`Wrangler login` failing inside container/devcontainer (still)

Open
#13,258 3 comments 0 reactions 2 assignees Claimed by @MattieTK View on GitHub
package:wrangler
Dominant language
TypeScript
Stars
4.5k
Forks
1.5k
Avg merge
3d 8h
Merged PRs (30d)
187

Description

### What versions & operating system are you using?

mcr.microsoft.com/devcontainers/typescript-node:24-trixie
Wrangler 4.80.0
Windows 11 WSL2

### Please provide a link to a minimal reproduction

No need, minimal repro is in the description

### Describe the Bug

devcontainer.json
```json
{
"name": "my-app devcontainer",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached",
"workspaceFolder": "/workspace",
"image": "mcr.microsoft.com/devcontainers/typescript-node:24-trixie",
"features": {
"ghcr.io/devcontainers-extra/features/pnpm:2": {}
},
"forwardPorts": [8787,8976],
"postCreateCommand": "pnpm install",
"customizations": {
"vscode": {
"extensions": [
"jacano.vscode-pnpm"
]
}
}
}
```

package.json
```json
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"packageManager": "pnpm@10.28.0",
"scripts": {
"build": "webpack --mode=development --config webpack.development.config.js",
"build-watch": "webpack --mode=development --config webpack.development.config.js --watch",
"build-prod": "webpack --mode=production --config webpack.production.config.js",
"dev": "pnpm build && wrangler dev",
"deploy": "wrangler deploy",
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20250327.0",
"@tailwindcss/postcss": "^4.1.11",
"copy-webpack-plugin": "^12.0.2",
"css-loader": "^7.1.2",
"css-minimizer-webpack-plugin": "^7.0.0",
"mini-css-extract-plugin": "^2.9.0",
"postcss": "^8.4.39",
"postcss-loader": "^8.1.1",
"tailwindcss": "^4.1.11",
"terser-webpack-plugin": "^5.3.10",
"typescript": "^5.7.0",
"webpack": "^5.94.0",
"webpack-cli": "^6.0.1",
"webpack-dev-server": "^5.2.2",
"webpack-merge": "^6.0.1",
"wrangler": "^4.0.0"
}
}
```

These two are all I'm running to get the latest wrangler installed inside a devcontainer I'm using.

1. `pnpm install` to pull wrangler down
2. `pnpm wrangler login --callback-host 0.0.0.0` following instructions on https://developers.cloudflare.com/workers/wrangler/commands/general/#use-wrangler-login-in-a-container
3. Link is generated, browser fails to open automatically for me (which is fine). I paste the link into my browser and confirm that the callback host has been switched to `localhost` (which I used to have to do manually).
4. I am presented with the OAuth authorization screen and click the approve button
5. The browser reports that wrangler is authenticated. At the same time, my wrangler instance logs some log lines, the login server exits (I can see the port-forwarding turn off in VSCode at this time), but the main thread is still hanging and not proceeding to complete the authentication process.

Proof that port-forwarding misconfiguration is not the problem (Ports tab in VSCode shows open connection to the temporary login server):

Image

Impact is pretty big as I am not authorized to provision a Cloudflare API token at this time at my enterprise.

### Please provide any relevant error logs

```

--- 2026-04-03T11:56:31.272Z debug
🪵 Writing logs to "/home/node/.config/.wrangler/logs/wrangler-2026-04-03_11-56-31_149.log"
---

--- 2026-04-03T11:56:31.272Z debug
.env file not found at "/workspace/.env.local". Continuing... For more details, refer to https://developers.cloudflare.com/workers/wrangler/system-environment-variables/
---

--- 2026-04-03T11:56:31.277Z log

⛅️ wrangler 4.80.0
───────────────────
---

--- 2026-04-03T11:56:31.282Z debug
Metrics dispatcher: Posting data {"deviceId":"bfc946bc-4224-45ba-8a4b-2250b867ac20","event":"wrangler command started","timestamp":1775217391282,"properties":{"amplitude_session_id":1775217391281,"amplitude_event_id":0,"wranglerVersion":"4.80.0","wranglerMajorVersion":4,"wranglerMinorVersion":80,"wranglerPatchVersion":0,"osPlatform":"Linux","osVersion":"#1 SMP PREEMPT_DYNAMIC Thu Jun 5 18:30:46 UTC 2025","nodeVersion":24,"packageManager":"pnpm","isFirstUsage":false,"configFileType":"jsonc","isCI":false,"isPagesCI":false,"isWorkersCI":false,"isInteractive":true,"hasAssets":true,"agent":null,"argsUsed":["callbackHost"],"argsCombination":"callbackHost","sanitizedCommand":"login","sanitizedArgs":{}}}
---

--- 2026-04-03T11:56:31.292Z log
Attempting to login via OAuth...
---

--- 2026-04-03T11:56:31.300Z log
Temporary login server listening on 0.0.0.0:8976
---

--- 2026-04-03T11:56:31.300Z log
Note that the OAuth login page will always redirect to `localhost:8976`.
If you have changed the callback host or port because you are running in a container, then ensure that you have port forwarding set up correctly.
---

--- 2026-04-03T11:56:31.300Z log
Opening a link in your default browser: https://dash.cloudflare.com/oauth2/auth?response_type=code&client_id=54d11594-84e4-41aa-b438-e81b8fa78ee7&redirect_uri=http%3A%2F%2Flocalhost%3A8976%2Foauth%2Fcallback&scope=account%3Aread%20user%3Aread%20workers%3Awrite%20workers_kv%3Awrite%20workers_routes%3Awrite%20workers_scripts%3Awrite%20workers_tail%3Aread%20d1%3Awrite%20pages%3Awrite%20zone%3Aread%20ssl_certs%3Awrite%20ai%3Awrite%20ai-search%3Awrite%20ai-search%3Arun%20queues%3Awrite%20pipelines%3Awrite%20secrets_store%3Awrite%20containers%3Awrite%20cloudchamber%3Awrite%20connectivity%3Aadmin%20offline_access&state=wTcApzMAQG.XleaosfDNb6psCnrcZHcn&code_challenge=tJSZ7GWeHptr3mWnJCRkg7n0uBxoPAH1U8kRU-dqnyk&code_challenge_method=S256
---

--- 2026-04-03T11:56:31.352Z warn
▲ [WARNING] Failed to open

---

--- 2026-04-03T11:56:48.113Z debug
fetching auth token grant_type=authorization_code&code=164PnoGhwpUnjGHZGBCojI_JjP7IReoLcOh66ZmcyJc.0MWcvnuBwbWTcr7t3nyScjccKQPPEPlTpPzdb4d_nmU&redirect_uri=http%3A%2F%2Flocalhost%3A8976%2Foauth%2Fcallback&client_id=54d11594-84e4-41aa-b438-e81b8fa78ee7&code_verifier=Q1V6N0tjU0pISS5vTWFoWXJKVHV-T0lYSXlBMl9-a2J1WUJULjlMZWJyYW15ZVpPeF8yLTdJOS4uazlERmNrWktHTXVCckVLYmdDZWg1Y1FiLnBLNWYtUWhIVVZCQmkt
---

--- 2026-04-03T11:56:48.113Z debug
Checking if domain has Access enabled: dash.cloudflare.com
---

--- 2026-04-03T11:56:48.113Z debug
Access switch not cached for: dash.cloudflare.com
---

--- 2026-04-03T11:56:48.447Z debug
Caching access switch for: dash.cloudflare.com
---

--- 2026-04-03T11:56:48.447Z debug
Fetching auth token from https://dash.cloudflare.com/oauth2/token
---

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.