I use Nodejs with Mongodb connection, it works. I didn't not change anything in code . Now I can't connect to mongodb. When I try connect with Robomongo when I don't use ssh I can't connect
But when I try to connect with ssh I can connect. My connection is success.
I can't understand problem.
My nodejs mongo connection in in here:
MongoClient.connect('mongodb://username:password@ipadress/dbname', (err, database) => {
if (err) return console.log(err)
db = database
app.listen(process.env.PORT || 5000, () => {
console.log('listening on 5000')
})
})
Thank you for help.
Your mongodb is not listening on the external interface but on localhost only so you can't connect directly to the 139.xxx IP.
However, if you use SSH it will first tunnel into the host and then connect locally so it works.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.