I have a MongoDB server running on my localhost. I wrote a simple Python program that reads/writes to the database using "localhost"; however, I want to give other clients access to my MongoDB server. For now, I am not concerned about access security and would like to grant access to anyone. How should I configure the Mongo Server to do this?
Here is the simple program connecting to localhost.
from pymongo import MongoClient
connection = MongoClient("Localhost")
db = connection.hockey.players
results = db.find()
print()
print('+-+-+-+-+-+-+-+-+-+-+-+-+-+-')
for record in results:
print(record['name'] + ',',record['position'])
connection.close()
The error message I'm getting: File "C:/Users/Peter/PycharmProjects/Test/helloWorld.py", line 8, in for record in results: File "C:\Python34\lib\site-packages\pymongo\cursor.py", line 1097, in next if len(self.__data) or self._refresh(): File "C:\Python34\lib\site-packages\pymongo\cursor.py", line 1019, in _refresh self.__read_concern)) File "C:\Python34\lib\site-packages\pymongo\cursor.py", line 850, in __send_message **kwargs) File "C:\Python34\lib\site-packages\pymongo\mongo_client.py", line 777, in _send_message_with_response server = topology.select_server(selector) File "C:\Python34\lib\site-packages\pymongo\topology.py", line 142, in select_server address)) File "C:\Python34\lib\site-packages\pymongo\topology.py", line 118, in select_servers self._error_message(selector)) pymongo.errors.ServerSelectionTimeoutError: x.y.z.w:27017: timed out
Process finished with exit code 1
Below is my current localhost setup that works fine if I run it on my client which hosts the MongoDB. Current setup
Thanks