Hi, I'm hosting a MERN stack on my server and I ca...
# orm-help
m
Hi, I'm hosting a MERN stack on my server and I can't get the backend to talk with the MongoDB. Based on Googling the error I'm getting, the issue might be Prisma specific, although I'm not sure about that. Even if it's not Prisma specific, maybe someone here will be kind enough to help me through? 🙂 Database URL in my .env file:
<mongodb://mongo_db_admin>:<password for mongo_db_admin>@127.0.0.1/<database name>?retryWrites=true&w=majority&ssl=true
I've tried many variations on this URL, including putting a port after the hostname. I'm presenting the version that seems to get furthest before throwing an error.
✅ 1
Error:
Error: MongoDB error
Server selection timeout: No available servers. Topology: { Type: Unknown, Servers: [ { Address: 127.0.0.1:27017, Type: Unknown, Error: An error occurred during DNS resolution: could not resolve "127.0.0.1": InvalidDNSNameError }, ] }
0: migration_core::state::SchemaPush
at migration-engine/core/src/state.rs:349
m
If it's any help my query string starts with
Copy code
<mongodb+srv://admin>
Note the
+srv
m
I've got the following block in my nginx.conf file, to try to handle the non-http tcp request:
stream {
server {
listen 81;/var/storage/wd2tb/certificate/sanchyan.tech/privatekey.pem;
proxy_connect_timeout 20s;
proxy_timeout 10m;
proxy_pass mongo_backend;
}
upstream mongo_backend {
server 127.0.0.1:27017;
}
}
@matt murphy thanks, when I put the
+srv
in, it fails faster, with error:
Error: MongoDB error
An error occurred during DNS resolution: no record found for name: _mongodb._tcp.127.0.0.1. type: SRV class: IN
0: migration_core::state::SchemaPush
at migration-engine/core/src/state.rs:349
n
Did you get this Database URL from MongoDB Atlas?
m
No, but that's what I'm switching to trying.
n
Got it, Let me know if using MongoDB Atlas fixes it.