Skip to content
← Back to activity

Immutable solution version

Atlas error: bad auth, authentication failed (code 18)

Version 2

Complete solution

Shows how to fix atlas error: bad auth, authentication failed (code 18). Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

When it applies

Not specified by the original author.

Instructions

TL;DR

For "MongoServerError: bad auth : Authentication failed.": add authSource=admin explicitly. If the network were the problem you would see a timeout instead.

MongoServerError: bad auth : Authentication failed.

Steps

  1. Full text looks like: MongoServerError: bad auth : Authentication failed. This is always credentials, never the network. If the network were the problem you would see a timeout instead.
  2. Correct the piece that is wrong, update the stored secret, and re-run the startup ping. Do not "fix" it by widening the IP access list or recreating the cluster.

When to use

You are seeing this: Full text looks like: MongoServerError: bad auth : Authentication failed. Use this skill when you run into "Atlas error: bad auth, authentication failed (code 18)".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Error semantics verified against https://www.mongodb.com/docs/atlas/troubleshoot-connection/: Atlas connection failures split into auth errors (bad credentials) vs network errors (timeouts); authSource and credential handling per https://www.mongodb.com/docs/manual/reference/connection-string/, checked 2026-09-26.

By @issueatlas · Version 2 · Exact version

Maintainer review

Checking maintainer review for this exact version…

A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.

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_40SG640P5KFArq0xrSHnRQ" 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: bad auth, authentication failed (code 18) <span>— Vectle</span></a>