-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mongo Atlas - MongoServerSelectionError: getaddrinfo ENOTFOUND #833
Comments
I'm having the same problem, everything was working fine last week. I'm not sure why the connection stopped working all of the sudden. |
The issue seems to be related to typeorm version 0.2.29 according to this typeorm/typeorm#7009 . Adding this to your package.json should fix the issue temporarily until they fix it Edit: I forgot to mention, this workaround only works if you are using yarn. Otherwise use @unflawed solution instead |
Having same issue and adding |
Fixed. If you get this, you need to install and import the
// _app.ts or _app.js
import "reflect-metadata";
... Suggest making this clearer in the docs if possible. |
Worked for me. Thanks! 👍 |
Thank you for the updates, linking to the outstanding issue and for a workaround (and confirming it works for you). I'm going to keep an eye on the open issue with typeorm to see if we will should make a change to address or if it's an issue they plan to address upstream. |
I just switched from mLab to Mongo Atlas, and started having the same problem. I found this thread, and switched from If I switch back to 0.2.29 or use any kind of semantic version auto-upgrade option (^ or ~ or .x) in the version, it uses the latest, and also has a problem. Locking the typeorm node module version to 0.2.28 seems to resolve the issue. |
FWIW, before I changed the typeorm version down to 0.2.28, I did a bunch of testing elsewhere. All connection strings, mongodb:// and mongo+srv://, worked everywhere else I tested them. The |
Still error, I can't fix this... |
Guys, did you fix it? @jrista |
fixed by this command |
@unflawed your solution worked for me, thanks so much! ❤️ |
I had been struggling with this for last five hours or so. @BskSmoothie's solution solved it for me. |
Solved for me! Thanks @jrista :) |
@iaincollins Could you pin this issue so it's easier for other Adding the resolution to my |
@IRediTOTO I fixed it by falling back to 0.2.28. The issue seems to be with 0.2.29. |
What does your database connection object look like as well as URL? Mongodb version? did you use npm or yarn? |
@andrewgwallace I am currently using a mongo:// connection string. |
To resolve for now without any "hackery", simply bypass the string parser's reliance on typeorm in the adapter and construct the object yourself. This way you don't have to install a previous typeorm version, modify your package.json, or include reflect-metadata. If your string looks like this: In your options for NextAuth, make your
Important: Note that it says uri and not url. Optional values such as Source of the issue seems to be coming from typeorm config. |
For whatever reason my comment got lost. Here it is again:
|
Worth mentioning is that I couldn't get the email configuration to work, until I changed it from a string to an object, just as you said about the connection string. |
@andrewgwallace Thank you for the update. Sounds like its due to parsing a full string url down into the various connection config parts then... For my purposes, I don't actually need mongodb+srv. Not at this stage of the project, anyway. So falling back to a mongodb:// url worked ok for me. Good to know that I can use an object for config though. |
not sure if I am the only one, but I haven't been able to get it working with any method in this thread so far. |
I have same problems and solution suggested by @andrewgwallace does not work for me :( |
@huksley have you tried this? |
@unflawed Yes, downgrading to |
sorry I was wrong, setting a resolutions for |
Yea -- my solution stopped working for me as well. 😭 For now, the stability of NextAuth and MongoDB Atlas is not sufficient enough for production use IMO. I'll keep an eye on this and other tickets for progress. Just going to note current key settings here where I last had it. If someone spots an issue let me know.
_app.js
|
@andrewgwallace try changing "optionalDependencies" to "peerOptionalDependencies" in your package.json like so: |
Yes that seems to have resolved it! Thank you @SelvinM ! Had to install mongodb as a dependency of course. |
I was able to fix it using the following config in
|
fixed thanks a lot . |
Pinned typeorm version to work around issue nextauthjs/next-auth#833
This worked for me
|
Although it hasn't been released yet, the PR to fix this in TypeORM has been merged. |
This worked for me:
and adding this in the "resolutions": {
"typeorm": "0.3.0-alpha.24"
}, |
@matiastucci 's solution works for me with npm + npm-force-resolutions |
@Zertz @matiastucci Thanks for the update! Great to know there is a fix in progress with TypeORM! Will get that rolled in and we can update the dependencies and docs when typeorm@0.3.0 is out. |
Fix should be available in the latest |
this is available in the latest canary release! |
We just updated to 0.2.31, then tried 0.2.30 as well...and we seem to have lost the ability to connect to an ObjectRocket Mongo DB with a normal mongo:// connection string. We connected to a local mongo fine, but the ObjectRocket is the service we use in all of our non-local environments. Not real sure what the issue is...it just seems to time out trying to connect. |
|
Your question
What am I missing using Mongo Atlas?
What are you trying to do
[next-auth][error][adapter_connection_error] MongoServerSelectionError: getaddrinfo ENOTFOUND cluster0.bixqg.mongodb.net
vercel
to run it not locally - the same resultFeedback
My code:
The full error:
The text was updated successfully, but these errors were encountered: