wasmerio/wasmer · error
❌ Failed to receive token from localhost
Error message
❌ Failed to receive token from localhost
What it means
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.
Source
Thrown at lib/cli/src/commands/auth/login/mod.rs:155
eprintln!("Error serving connection: {e:?}");
}
});
},
_ = futs.next() => {}
_ = server_shutdown_rx.recv() => {
// stop the accept loop
break;
}
}
}
// receive the token from the server
let token = token_rx
.recv()
.await
.ok_or_else(|| anyhow::anyhow!("❌ Failed to receive token from localhost"))?;
Ok(token)
}
async fn do_login(&self, env: &WasmerEnv) -> anyhow::Result<AuthorizationState> {
let client = env.client_unauthennticated()?;
let should_login =
if let Some(user) = wasmer_backend_api::query::current_user(&client).await? {
#[cfg(not(test))]
{
println!(
"You are already logged in as {} in registry {}.",
user.username.bold(),
env.registry_public_url()?.host_str().unwrap().bold()
);
let theme = dialoguer::theme::ColorfulTheme::default();
let dialog = dialoguer::Confirm::with_theme(&theme).with_prompt("Login again?");View on GitHub (pinned to 8c4b9ee9d3)
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.
Defensive patterns
Strategy: try-catch
Validate before calling
// ensure the localhost callback port is free before starting browser login ss -ltn | grep -q ':<port> ' && echo "callback port in use - close the process or pick another"
Try / catch
match get_token_from_browser(&client, &server_url).await {
Ok(token) => token,
Err(e) if e.to_string().contains("Failed to receive token from localhost") => {
eprintln!("browser login not completed; falling back to token login");
prompt_for_manual_token().await?
}
Err(e) => return Err(e),
} Prevention
- 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.
When it happens
Trigger: `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.
Common situations: 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.
Related errors
- The backend did not return any nonce to auth the login!
- Not logged in!
- config from file: {e}
- No registry not specified!
- Not logged into registry {host_str}
AI-assisted analysis of wasmerio/wasmer@8c4b9ee9d3 (2026-09-01).
Data as JSON: /api/errors/43bbbd5e50e20a72.
Report an issue: GitHub.