Why can’t you use mongodb online database to automatically create a local database with the error’ collection’ of null?

  mongodb, question
var MongoClient = require('mongodb').MongoClient;
 // var DB_CONN_STR = 'mongodb://localhost:27017/runoob';
 var DB_CONN_STR =  'mongodb://root:root@129.23.78.121:27017/runoob';  (For safety: don't try.  I changed the password and ip)
 
 
 var insertData = function(db, callback) {
 //connect to table site
 var collection = db.collection('site');
 //insert data
 Var data = [{"name ":"rookie tutorial ","url":"www.runoob.com"},{"name ":"rookie tool ","url":"c.runoob.com"}];
 collection.insert(data, function(err, result) {
 if(err)
 {
 console.log('Error:'+ err);
 return;
 }
 callback(result);
 });
 }
 
 MongoClient.connect(DB_CONN_STR, function(err, db) {
 Log ("connection succeeded!"  );
 insertData(db, function(result) {
 console.log(result);
 db.close();
 });
 });

Using the local database to create the success graph below:

var DB_CONN_STR = 'mongodb://localhost:27017/runoob';

clipboard.png

Using Online Database to Create Failure Diagram Below:

var DB_CONN_STR =  'mongodb://root:root@129.23.78.121:27017/runoob';

clipboard.png

References:http://www.runoob.com/nodejs/ …

Update (Resolved)
Because I use the mongodb connection name as the server user and password.

The direction upstairs is correct, you directly used the database without judging whether the connection was successful or not, and your situation is indeed a failure.
What you said in robo 3T is called SSH Tunnel——SSH Tunnel, which means that when you connect to the target database, first connect to the remote through SSH, then connect to the database through this connection, which is equivalent to connecting MongoDB in the remote LAN.
No matter who set up such a mechanism, this is completely in line with the norms and is the right decision. The purpose of this is to prevent someone from connecting to the database remotely-unless you have an SSH connection to transfer for you. SSH tunneling is usually only applicable to administrative work because it is safe, but neither efficient nor stable. This is unacceptable for a program to connect to a database, so this method is not supported when the program connects, and should not be supported because it is meaningless in actual use.
I don’t know why you want to connect to the online environment locally, not to say that you can’t do it, but this is quite dangerous, and it is strongly recommended not to do so.