README troubleshooting

Hello! I’m trying to get through the README. I can confidently connect to my cluster through both the Mongo shell and Mongo Compass, but I’ve tried a few configurations of the .env file and get the following errors:

Test 1
Changed my mongodb URI to mongodb+srv://m220student:m220password@mflix-shard-00-01-vvjlb.mongodb.net/test?retryWrites=true and ran from the containing folder.

Results:
The following output

(directories)\mflix-js>npm start

> server@1.0.0 start (directories)\mflix-js
> nodemon -L ./index.js

[nodemon] 1.19.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node ./index.js`
Error: querySrv ENOTFOUND _mongodb._tcp.mflix-shard-00-00-vvjlb.mongodb.net
    at QueryReqWrap.onresolve [as oncomplete] (dns.js:196:19)

Test 2
Changed mongo URI to have port 27017 at end.

Results

MongoParseError: Ports not accepted with 'mongodb+srv' URIs

This is understandable, I think.

Test 3
Used npm install again in correct directory to see if any input changed.

Results

(directories)\mflix-js\node_modules\weak-napi\src\weakref.cc(2): fatal error C1083: Cannot open include file: 'setimmediate.h': No such file or directory [(directories)\mflix-js\node_modules\weak-napi\build\weakref.vcxproj]

Test 4
Attempted to add URI of each node, comma-separated

Results

MongoParseError: Invalid URI, cannot contain multiple hostnames

Any help on this would be greatly appreciated, thank you!

Your URI seems wrong. I have never seen an SRV connection string explicitly listing a specific shard. Please verify with your atlas server.

1 Like

Great, that solved my issue - just connect to the cluster, not a specific shard! Cheers :beers: