Итак, я не могу подключиться к MongoDB (Atlas). Кажется, я схожу с ума здесь, потому что бревна так же полезны, как якорь на тонущей лодке. Вот что происходит. Спасибо за помощь.
Вот мой сервер. js file:
'use strict';
const mongodb = require('mongodb');
const http = require('http');
const nconf = require('nconf');
let uri = 'mongodb://USERNAME:PASSWORD@cluster0-w4hci.mongodb.net/test?retryWrites=true&w=majority;';
Вот что говорит консоль
npm start
> test@1.0.0 start /home/XXXXXXX
> node server.js
mongodb://USERNAME:PASSWORD@cluster0-w4hci.mongodb.net/test?retryWrites=true&w=majority;
/home/XXXXXXX/node_modules/mongodb/lib/mongo_client.js:421
throw err
^
MongoError: failed to connect to server [cluster0-w4hci.mongodb.net:27017] on first connect [MongoError: getaddrinfo ENOTFOUND cluster0-w4hci.mongodb.net cluster0-w4hci.mongodb.net:27017]
at Pool.<anonymous> (/home/XXXXXXX/node_modules/mongodb-core/lib/topologies/server.js:336:35)
at emitOne (events.js:116:13)
at Pool.emit (events.js:211:7)
at Connection.<anonymous> (/home/XXXXXXX/node_modules/mongodb-core/lib/connection/pool.js:280:12)
at Object.onceWrapper (events.js:317:30)
at emitTwo (events.js:126:13)
at Connection.emit (events.js:214:7)
at Socket.<anonymous> (/home/XXXXXXX/node_modules/mongodb-core/lib/connection/connection.js:187:49)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test@1.0.0 start: `node server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/XXXXXXX/.npm/_logs/2020-02-23T15_17_31_259Z-debug.log