# Atlas AuthError: Failed to write auth data

> Failed to write auth data is a filesystem error, not a bad credential. Fix permissions or disk space, then re-run `atlas auth login`.

Atlas raises an AuthError whose message is Failed to write auth data when saving a credential fails at the filesystem layer, not because the credential itself is wrong. Auth.set writes the auth file with mode 0o600 and maps any filesystem failure into the tagged AuthError with that message, so a permissions or disk problem is not mistaken for a bad credential. Check permissions and ownership on the Atlas auth file and its parent directory, confirm the disk is not full and the home directory is writable, and on a shared machine make sure the file is not owned by another user. Then re-run `atlas auth login`.

## Symptom

Saving a credential in Atlas fails with an AuthError whose message is: Failed to write auth data. The login flow itself may have succeeded, but the credential is not persisted, so the next Atlas command asks you to authenticate again.

## Cause

Atlas's Auth.set writes the auth file with mode 0o600 and maps any filesystem failure into the tagged AuthError with the message Failed to write auth data, so a permissions or disk problem is not mistaken for a bad credential. A full disk, a read-only home directory, or an auth file owned by another user all produce this error.

## Fix

1. Check permissions and ownership on the Atlas auth file and its parent directory. Auth.set writes the file with mode 0o600, so the user running Atlas must be able to write it.
2. Confirm the disk is not full and the home directory is writable. A full filesystem produces Failed to write auth data even though the credential itself is valid.
3. On a shared machine, make sure the auth file is not owned by another user. Atlas writes it 0o600 for a reason, and a file owned by someone else cannot be rewritten by you.
4. Re-run `atlas auth login` once the filesystem problem is fixed, so the credential is written and persisted.
5. Run an Atlas command that needs the credential and confirm it does not ask you to authenticate again.

## Why does Atlas say Failed to write auth data

Atlas says Failed to write auth data because Auth.set could not write the auth file. Auth.set writes that file with mode 0o600 and maps any filesystem failure into the tagged AuthError with exactly this message, which means the credential you supplied is almost certainly fine and the filesystem is the problem.

The distinction matters. If Atlas reported a generic authentication failure here, you would spend your time re-checking API keys that were never wrong. Instead, Failed to write auth data is a specific, tagged AuthError that says the write itself failed. The three things that break the write are permissions on the auth file or its parent directory, a full disk, and, on shared machines, an auth file owned by a different user. None of those are fixed by logging in again until the filesystem problem is fixed first.

## How to fix permissions on the Atlas auth file

Check permissions and ownership on the Atlas auth file and its parent directory. Atlas's Auth.set writes the file with mode 0o600, meaning read and write for the owner only, so the user running Atlas must own the file and must be able to write into the directory that holds it.

Confirm the parent directory exists and is writable by the account running Atlas. Then confirm the auth file itself, if it already exists, is owned by that same account. A file created earlier by a different user, by a root-elevated run, or by a container mounting your home directory can be perfectly readable and still be impossible for you to rewrite. Fixing ownership and permissions, then re-running `atlas auth login`, resolves the write. Do not loosen the mode beyond 0o600: Atlas writes it 0o600 for a reason, because the file holds credentials.

## How to fix Failed to write auth data on a full disk

A full disk produces Atlas's Failed to write auth data even when the credential is perfectly valid, because Auth.set writes the auth file with mode 0o600 and maps any filesystem failure into the tagged AuthError. Confirm the disk is not full and the home directory is writable, then re-run `atlas auth login`.

Check free space on the filesystem that holds your home directory, not just on the volume you happen to be working in. A separate home partition can fill while the working volume looks fine. A read-only home directory, which happens in some container and remote setups, has the same effect: the write is refused and Atlas reports Failed to write auth data. Free space or restore write access, then re-run `atlas auth login` so the credential is actually persisted.

## Why Failed to write auth data hits shared machines

Shared machines hit Atlas's Failed to write auth data most often, because Auth.set writes the auth file with mode 0o600 and a file already owned by another user cannot be rewritten. On a shared machine, make sure the auth file is not owned by another user before re-running the login.

Mode 0o600 means only the owner can read or write the auth file, which is exactly what you want for stored credentials, and it is also why a second user on the same machine cannot overwrite the first user's file. If two accounts share a home directory, or if someone ran Atlas under sudo and left a root-owned auth file behind, the next non-root login fails with Failed to write auth data. Correct the ownership so the account running Atlas owns the file, then authenticate again.

## How to verify the auth write worked

Verify the fix by re-running `atlas auth login` and confirming no AuthError with the message Failed to write auth data appears. Because Auth.set only raises that tagged AuthError when the filesystem write fails, a silent login means the auth file was written with mode 0o600 and the credential is persisted.

Confirm persistence, not just a quiet login. Run an Atlas command that needs the credential and check that it does not prompt you to authenticate again, which is the real signal that the write survived. If Failed to write auth data reappears, the filesystem problem is still present: re-check ownership on both the auth file and its parent directory, and re-check free space on the volume holding your home directory.

## FAQ

### What does Failed to write auth data mean in Atlas?

It means Atlas's Auth.set could not write the auth file. Auth.set maps any filesystem failure into a tagged AuthError with that message, so the cause is permissions, ownership, or disk space, not a bad credential.

### Is Failed to write auth data a bad API key?

No. Atlas deliberately distinguishes the two. Auth.set maps filesystem failures into the AuthError with the message Failed to write auth data so a permissions or disk problem is not mistaken for a bad credential.

### What permissions does the Atlas auth file need?

Auth.set writes the Atlas auth file with mode 0o600, read and write for the owner only. The account running Atlas must own the file and be able to write into its parent directory.

### How do I fix Failed to write auth data on a shared machine?

Make sure the auth file is not owned by another user. Atlas writes it 0o600, so a file left behind by another account or by a sudo run cannot be rewritten by you. Fix ownership, then re-run `atlas auth login`.

### Can a full disk cause an Atlas AuthError?

Yes. Confirm the disk is not full and the home directory is writable. Auth.set maps any filesystem failure, including a full disk, into the AuthError with the message Failed to write auth data.

### Do I need to re-run atlas auth login after fixing permissions?

Yes. The credential was never persisted, so re-run `atlas auth login` once the filesystem problem is fixed, then run a command that needs the credential to confirm it does not prompt again.

### Should I loosen the 0o600 mode on the Atlas auth file?

No. Atlas writes the auth file 0o600 for a reason, because the file holds credentials. Fix ownership and disk space instead of widening the permissions.

---

Canonical HTML: https://runatlas.sh/resources/troubleshooting/auth-storage-write-failed
Source of truth: aeo_pages row `/resources/troubleshooting/auth-storage-write-failed` (segment: Troubleshooting) (this file is generated from it, never hand-edited).
Licence: Atlas is proprietary with a free core. It is not open source and there is no public source repository.
