You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

新手求助:goorm IDE连接MongoDB Atlas时出现认证失败错误

Troubleshooting MongoDB Atlas Authentication Failure in Goorm IDE

Hey Dylan, sorry to hear you're stuck with this auth error! Let's walk through the most common fixes for this bad auth Authentication failed issue, since you already sorted the IP whitelist (0.0.0.0/0 is correct for allowing all connections).

1. Fix the Connection String's Escaped Ampersand

Looking at your code, the biggest red flag is the & in your MongoDB connection string. This is an HTML-escaped version of &, and Mongoose will interpret it as part of the string rather than a parameter separator—this is almost certainly causing part of your auth issue.

Your current connection string:

mongoose.connect('mongodb+srv://dylanOh:123456@cluster0-1kwgi.mongodb.net/test?retryWrites=true&w=majority',{ useNewUrlParser : true, useCreateIndex : true })

Replace it with this (swap & for & + add a critical connection parameter):

mongoose.connect('mongodb+srv://dylanOh:123456@cluster0-1kwgi.mongodb.net/test?retryWrites=true&w=majority',{ 
  useNewUrlParser: true, 
  useCreateIndex: true, 
  useUnifiedTopology: true 
})

I added useUnifiedTopology: true—this is required for newer Mongoose versions to properly handle Atlas's cluster topology, which can also cause silent connection failures.

2. Double-Check Your Atlas Database User Credentials

Even tiny typos can break authentication:

  • Head to your MongoDB Atlas dashboard → Database Access
  • Verify the username is exactly dylanOh (usernames are case-sensitive!)
  • Confirm the password matches 123456—if you recently updated it, make sure the string in your code reflects the new password. (Note: If your password had special characters, you'd need to URL-encode them, but 123456 is safe as-is.)

3. Ensure Your Atlas User Has Proper Permissions

Make sure the database user you created has enough access to connect and interact with the database:

  • In Database Access, edit the dylanOh user
  • Under "Built-in Role", select at least readWrite (or dbOwner for full access during testing)
  • Save the changes and wait 1-2 minutes for permissions to propagate across Atlas's servers

4. Verify Mongoose Version Compatibility

Outdated Mongoose versions can have bugs with Atlas's SRV connection strings. Run this in your Goorm IDE terminal to check your version:

npm list mongoose

If it's older than v5.10.0, update it with:

npm install mongoose@latest

Try these steps in order—fixing the & issue is the most likely quick win here. Once you make the changes, restart your server and see if you get the "Connected to DB!" message.

内容的提问来源于stack exchange,提问作者Dylan Oh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 07:02:17