-
-
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 configuration #314
Comments
Hmm the It might be helpful to try using |
Tried with step 3 and 4 strings and got the same errors, I installed mongodb's official driver like docs said but maybe I'm missing another thing? |
Hmm thanks. Just to check, are you literally using the hostname |
Placeholders, the real ones are |
I did some digging, spin up a cluster on Atlas (mongodb.net) and got the same error. I got it working if I pass an object (rather than a string) and set "useNewUrlParser" to true. database: {
type: "mongodb",
useNewUrlParser: true,
url: process.env.DATABASE_URL,
}, I don't have to do this when invoking a connection from the mongodb driver directly, so this seems to be caused by something that TypeORM does with 'mongodb+srv' URLs. In a future update we can patch this to enable that option by default for |
First, thanks for answering so fast, a true lifesaver. It works but I had to remove the last part of the URL |
Oh awesome thanks for confirming! Doh I can see that same behaviour too. Not sure what to do about that yet! I think maybe you can pass them to TypeORM as options on the object (maybe in a property called 'extra'?). We can leave this open and I'll investigate that! |
I ran into the same mongo connection issues today, followed the steps in this thread (pass an object instead of the connection string) and got it working. Thanks! |
About the extra argument: I got this after a while |
I think you should be able to find an answer in the TypeORM docs / issues somewhere, it looks like talking to Atlas hosted DB's (with the mongdb+srv pragma) has come up a few times. I'll definitely try and see if we can abstract it automatically, to address whatever TypeORM is doing that is wrong. |
Yes. You don't need to use a database to use the callback functions. |
@VivianaGarces Thanks again for the bug report! Have created #328 to track it until we can handle it better by default. |
Your question
How can I use the mongodb+srv string on the .env file?
What are you trying to do
I've tried to use that notation since I saw on a previous post that this was running correctly but when I try to connect I get a failed to connect to server on first connect
I tried several things
For reference:
Step 3 string: mongodb+srv://user:password@cluster0-server0.gcp.mongodb.net/dbname?retryWrites=true&w=majority
Step 4 string: mongodb+srv://user:password@cluster0-shard-00-01-server0.gcp.mongodb.net/dbname?retryWrites=true&w=majority
Appreciate the help.
Documentation feedback
The text was updated successfully, but these errors were encountered: