Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

215
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda