Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

212
Views
how to connect another machine mongodb database inside local network ?

I follow this mongoose document enter link description here

mongoose.connect('mongodb://localhost/waterDB');

Using This, I can connect local machine waterDBmongoDB DataBase

My Personal Machine Local IP : 192.168.1.5

My Server Machine Local IP : 192.168.1.100

Both machine have waterDB DataBase . There is no username and password for both DB

I wanted to connect Server Machine waterDB Inside My Personal Machine.

According To This : mongoose.connect('mongodb://username:password@host:port/database?options...');

I try : mongoose.connect('mongodb://192.168.1.100:27017/waterDB');

But,

MongoError: failed to connect to server [192.168.1.100:27017] on first connect
at null.<anonymous> (/home/water/node_modules/mongodb-core/lib/topologies/server.js:313:35)
at emitOne (events.js:77:13)
at emit (events.js:169:7)
..........

Any solution for err ?

Thank (@_@)

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

It might be a problem with your MongoDB instance listening on localhost only. You can change the bind address in MongoDB's configuration file. The config file may be located in /etc/mongodb.conf or /etc/mongod.conf. There are also 2 config file formats:

Old format (still supported):

bind_ip = 0.0.0.0

YAML (version 2.6+):

net:
    bindIp: 0.0.0.0

After changing the config file you have to restart the MongoDB server.

over 4 years ago · Santiago Trujillo Report

0

Try without the Port no.

mongoose.connect('mongodb://192.168.1.100/waterDB');

this should work for you.

But make sure both are connected on the same network, if you are connected on other network than your server is, then it wont work

over 4 years ago · Santiago Trujillo Report

0

You will have to use SSH tunnel in this case. Refer to the following link which shows how you can create SSH tunnel.
Node.js SSH Tunneling to MongoDB using Mongoose

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!