I'm beginner in node.js and trying to run mongodb.
It works well with remote connection link, but I have no stable internet connection, so I need to deal with it locally on Android device + Termux.
And I haven't found solution of this problem specifically for Termux.
Package npm mongodb is installed.
Just simple connection code:
const mongoose = require('mongoose')
const url = `mongodb://127.0.0.1:27017/myapp`;
mongoose.connect(url)
.then(() => console.log("Connected to mongodb successfully"))
.catch((err) => console.error(err))
The error details:
MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
at _handleConnectionErrors
(/storage/emulated/0/app/node_modules/mongoose/lib/connection.js:829:11)
at NativeConnection.openUri
(/storage/emulated/0/app/node_modules/mongoose/lib/connection.js:804:11) {
reason: TopologyDescription {
type: 'Unknown',
servers: Map(1) { '127.0.0.1:27017' => [ServerDescription] },
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: null,
maxElectionId: null,
maxSetVersion: null,
commonWireVersion: 0,
logicalSessionTimeoutMinutes: null
},
code: undefined
}