atuinsh/atuin · error

username already in use

Error message

username already in use

What it means

`register` first probes `GET /user/<username>`; if the server responds with success, the username is already taken and registration aborts with this error. The actual `POST /register` is never attempted.

Solutions

  1. Run `atuin login -u <username>` instead — you likely already have an account
  2. Choose a different username for registration
  3. Check for typos in the username
  4. If you lost your password, use the server's account recovery rather than re-registering

Example fix

// before
atuin register -u alice -e a@b.c -p 'pass'
// after (account exists)
atuin login -u alice
Defensive patterns

Strategy: validation

Validate before calling

// before register, probe the username the same way the client does
let probe = client.get(format!("{address}/user/{username}")).send().await?;
if probe.status().is_success() {
    eprintln!("username taken — use `atuin login` instead");
    return Ok(());
}

Try / catch

match register(&client, &address, username, email, password).await {
    Err(e) if e.to_string() == "username already in use" => {
        login(&client, &address, username, password).await? // fall back to login
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling `atuin register` (or `register()` in api_client) with a username that already exists on the sync server.

Common situations: Re-running registration on a machine where you already signed up, choosing a common username, or pointing at a server where your username is claimed by someone else.

Related errors


AI-assisted analysis of atuinsh/atuin@900007c480 (2026-09-19). Data as JSON: /api/errors/2a0241e2d3e4774f. Report an issue: GitHub.

Appendix: source

Thrown at crates/atuin-client/src/api_client.rs:146

    password: &str,
    extra_headers: &HashMap<String, String>,
) -> Result<RegisterResponse> {
    let mut map = HashMap::new();
    map.insert("username", username);
    map.insert("email", email);
    map.insert("password", password);

    let mut headers = extra_headers_map(extra_headers)?;
    headers.insert(USER_AGENT, APP_USER_AGENT.parse()?);
    headers.insert(ATUIN_HEADER_VERSION, ATUIN_CARGO_VERSION.parse()?);

    let client = client_builder(extra_headers).build()?;

    let url = address.append(["user", username])?;
    let resp = client.get(url).headers(headers.clone()).send().await?;

    if resp.status().is_success() {
        bail!("username already in use");
    }

    let url = address.append(["register"])?;
    let resp = client.post(url).headers(headers).json(&map).send().await?;
    let resp = handle_resp_error(resp).await?;

    if !ensure_version(&resp)? {
        bail!("could not register user due to version mismatch");
    }

    let session = resp.json::<RegisterResponse>().await?;
    Ok(session)
}

#[instrument(level = "trace", skip_all, err)]
pub async fn login(
    address: &Url,
    req: LoginRequest,

View on GitHub (pinned to 900007c480)