Application System IP: 10.0.0.15
MongoDB Server IP : 10.0.0.215
Here are a few details :
I'm running a Python web application on different system and mongo db on different system. Both systems can ping each other.
I have replaced socket ip to connect to mongo db from 127.0.0.1 to mongo db system ip.
Given MongoDB ip in application to connect but when running application I'm getting connection refused error.
Added MongoDB system private ip with localhost,127.0.0.1 to bind variable in /etc/mongod.conf bind_IP = 127.0.0.1, 10.0.0.215
Both systems are running on same network
dist-packages/pymongo/mongo_client.py also ?Screenshot of error: https://i.imgsafe.org/a733a2d.png
/// database.py file
import pymongo
class Database(object):
URI = "mongodb://127.0.0.1:27017"
DATABASE = None
@staticmethod
def initialize():
client = pymongo.MongoClient(Database.URI)
Database.DATABASE = client['fullstack']
@staticmethod
def insert(collection, data):
Database.DATABASE[collection].insert(data)
Sandeep Panda
co-founder, Hashnode
If your MongoDB server IP address is
10.0.0.215, you need to update URI in yourdatabase.pyfile tomongodb://10.0.0.215:27017/testdb.