Я новичок в изучении nodejs, и я развернул свое приложение api, используя express на a2Hosting для node js app, и я использую mon goose db после всех настроек конфигурации и запуска monodb. сервис на моем хосте VPS, я не могу подключиться к mon goose .connect (URI); и я получил эту ошибку.
MongoNetworkError: failed to connect to server [serverIPXX.XX.XX:27017] on first connect [Error: connect ECONNREFUSED 70.32.24.12:27017
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1056:14) {
name: 'MongoNetworkError',
[Symbol(mongoErrorContextSymbol)]: {}
}]
at Pool.<anonymous> (/home/perjoaho/nodevenv/PrjoApp/12/lib/node_modules/mongoose/node_modules/mongodb/lib/core/topologies/server.js:438:11)
at Pool.emit (events.js:209:13)
at /home/perjoaho/nodevenv/PrjoApp/12/lib/node_modules/mongoose/node_modules/mongodb/lib/core/connection/pool.js:561:14
at /home/perjoaho/nodevenv/PrjoApp/12/lib/node_modules/mongoose/node_modules/mongodb/lib/core/connection/pool.js:994:11
at /home/perjoaho/nodevenv/PrjoApp/12/lib/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connect.js:31:7
at callback (/home/perjoaho/nodevenv/PrjoApp/12/lib/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connect.js:264:5)
at Socket.<anonymous> (/home/perjoaho/nodevenv/PrjoApp/12/lib/node_modules/mongoose/node_modules/mongodb/lib/core/connection/connect.js:294:7)
at Object.onceWrapper (events.js:297:20)
at Socket.emit (events.js:209:13)
at emitErrorNT (internal/streams/destroy.js:91:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
at processTicksAndRejections (internal/process/task_queues.js:77:11) {
name: 'MongoNetworkError',
[Symbol(mongoErrorContextSymbol)]: {}
}
////////////
код подключения
mongoose.connect("mongodb://XX.XX.XX:27017/perjodb", {useNewUrlParser: true , useUnifiedTopology: true});
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function() {
// we're connected!
console.log("DB Connected");
});