0

My sails JS application looking for mongo db(Running on docker) , though local mongo db server is available. If docker is up with mongo db server then application connecting to docker based mongo-DB

{ name: 'MongoError',
  message: 'failed to connect to server [192.168.99.100:27017] on first connect' 
}
Raj N
  • 249
  • 1
  • 18

1 Answers1

0

In order to make the container connect to a local mongodb you need to get the ip of your host in linux you can type the following command on the host

ifconfig docker0 | awk '/inet / { print $2 }'

The result will be an ip that can be used to call it from any container followed by the service port which will be 27017 in your case. and make sure that the mongodb is not listening to 127.0.0.1 only.

Mostafa Hussein
  • 11,063
  • 3
  • 36
  • 61
  • SailJS application running locally mongoDB running on docker, so i have to connect to local mongo DB instead of docker based db – Raj N Mar 01 '19 at 08:53
  • If you want to connect to mongodb locally then this has nothing to do with docker. Just change the settings in your sails application to listen on 127.0.0.1:27017 – Mostafa Hussein Mar 01 '19 at 09:02