{"record":{"id":"43bbbd5e50e20a72","repo":"wasmerio/wasmer","slug":"failed-to-receive-token-from-localhost","errorCode":null,"errorMessage":"❌ Failed to receive token from localhost","messagePattern":"❌ Failed to receive token from localhost","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/cli/src/commands/auth/login/mod.rs","lineNumber":155,"sourceCode":"                            eprintln!(\"Error serving connection: {e:?}\");\n                        }\n                    });\n                },\n\n                _ = futs.next() => {}\n\n                _ = server_shutdown_rx.recv() => {\n                    // stop the accept loop\n                    break;\n                }\n            }\n        }\n\n        // receive the token from the server\n        let token = token_rx\n            .recv()\n            .await\n            .ok_or_else(|| anyhow::anyhow!(\"❌ Failed to receive token from localhost\"))?;\n\n        Ok(token)\n    }\n\n    async fn do_login(&self, env: &WasmerEnv) -> anyhow::Result<AuthorizationState> {\n        let client = env.client_unauthennticated()?;\n\n        let should_login =\n            if let Some(user) = wasmer_backend_api::query::current_user(&client).await? {\n                #[cfg(not(test))]\n                {\n                    println!(\n                        \"You are already logged in as {} in registry {}.\",\n                        user.username.bold(),\n                        env.registry_public_url()?.host_str().unwrap().bold()\n                    );\n                    let theme = dialoguer::theme::ColorfulTheme::default();\n                    let dialog = dialoguer::Confirm::with_theme(&theme).with_prompt(\"Login again?\");","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/wasmerio/wasmer/blob/8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5/lib/cli/src/commands/auth/login/mod.rs#L137-L173","documentation":"During browser login the CLI spins up a local HTTP server and waits on a oneshot/channel (`token_rx.recv()`) for the backend to redirect back with the auth token. `recv()` returns `None` when the channel's sender is dropped without sending a token, so the CLI raises this error. It means the local callback server closed before delivering a token.","triggerScenarios":"`wasmer login` browser flow: the redirect handler never fired (user closed the browser tab, never completed auth, or the callback hit the wrong port) and the sender was dropped.","commonSituations":"User abandons the login page and the CLI times out / the listener thread exits; browser blocks the localhost redirect (extensions, popup blockers); localhost port conflicts or firewalls on the callback port.","solutions":["Re-run `wasmer login` and complete the authorization in the opened browser tab.","Copy the auth URL into a different browser or incognito window if a popup blocker interfered.","If browser flow keeps failing, log in with a manually created token: `wasmer login <TOKEN>` from https://wasmer.io/settings/access-tokens.","Check that nothing on your machine (firewall, antivirus, another process) is intercepting the localhost callback."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// ensure the localhost callback port is free before starting browser login\nss -ltn | grep -q ':<port> ' && echo \"callback port in use - close the process or pick another\"","typeGuard":null,"tryCatchPattern":"match get_token_from_browser(&client, &server_url).await {\n    Ok(token) => token,\n    Err(e) if e.to_string().contains(\"Failed to receive token from localhost\") => {\n        eprintln!(\"browser login not completed; falling back to token login\");\n        prompt_for_manual_token().await?\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Complete the authorization in the opened tab promptly; don't close it early.","Disable popup blockers / allow localhost redirects for the login flow.","Use `wasmer login <TOKEN>` when browser interaction or localhost callbacks are unreliable."],"tags":["auth","login","localhost","callback"],"backgroundTag":"missing-oauth-token-callback","analyzedSha":"8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5","analyzedAt":"2026-09-01T23:06:31.009Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}