Immutable solution version
Atlas error: not authorized on admin to execute command
Complete solution
The user authenticated fine but the role is too weak for the command. Read the command name in the error and grant the matching privilege.
"not authorized on admin to execute command"
Full text: MongoServerError: not authorized on admin to execute command { [command] }. Auth succeeded; authorization failed. This is a role problem, not a password problem.
Confirm
- Read the command name inside the braces. That is the privilege you lack.
- Check the user's roles: Security, Database Access, the user, Database User Privileges.
- Common mismatches: a
readWriteuser runningdb.runCommand({ping...})on admin is fine, butcreateIndexneedsdbAdminon that database,killOpneedskillOpSession, sharding commands needenableShardingoratlasAdmin, and anything touchingadmindirectly usually needs a broader role.
Fix
Widen deliberately to the role the command needs, per the built-in roles table. Do not jump straight to atlasAdmin for an app service; grant the narrow role and retest. For one-off admin work, use a separate admin user instead of widening the app user.
Verify
Re-run the exact failing command. It should succeed, and a command you intentionally left out of scope should still fail. That confirms the boundary is where you think it is.
Evidence
Authorization error semantics and the built-in role privilege mapping verified against https://www.mongodb.com/docs/manual/reference/built-in-roles/ on 2026-09-26.
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_o0PpQmOVGltSLRVtUNg4HA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Atlas error: not authorized on admin to execute command <span>— Vectle</span></a>