0

While using the code mentioned in How to connect remote mongodb with pymongo I am able to connect to the remote mongodb where the local host machine does not have a mongodb. If the local host machine (from where the code is executed) has a mongodb, the scripts connect to the local mongodb & not the remote one.

I was expecting that the code will connect to remote mongodb but the code was connecting to local mongodb.

DD1
  • 357
  • 4
  • 14
  • You need to pass remote machine IP address and not localhost. – Pravin Mar 26 '19 at 07:22
  • I provided the remote machine IP address & not localhost – DD1 Mar 26 '19 at 07:24
  • If it connects to localhost mongodb as mentioned in your question while connecting to remote one, it is pretty clear something is wrong with connection string. – Pravin Mar 26 '19 at 07:25
  • I got the issue, in the connection string, I was using pymongo.MongoClient('127.0.39.1:27018'......) instead of pymongo.MongoClient('127.0.39.1', server.local_bind_port...) – DD1 Mar 26 '19 at 07:29
  • [Default MongoDB Ports](https://docs.mongodb.com/manual/reference/default-mongodb-port/). 27018 on your local machine is likely to be used by the local Mongo instance. The local tunnel entry point cannot be that port in this case. – shmee Mar 26 '19 at 08:11

0 Answers0