I have created a mongoDB VM instance in GAP, and I have a php application which is deployed in google app engine, in that application I want to add mongoDB,
for which I have created a mongo VM in GAP which have an internal and external IP,
so for the mongo connectivity, I was trying to add the external IP of the mongo VM instance in the mongod.conf file, which is present in etc/mongod.conf
So, when I try to make changes in the mongod.conf file i.e. if I try to change the bindIP from 0.0.0.0 to the external IP of mongoDB VM instance, the changes are possible
and after that when I try to restart the mongo service and check its status it gives me the below error
which gives me the below error
root@mongodb-3-servers-vm-0:/# sudo systemctl status mongod
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2022-02-07 05:42:47 UTC; 7s ago
Docs: https://docs.mongodb.org/manual
Process: 1691 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=2)
Main PID: 1691 (code=exited, status=2)
i checked the logs in /var/log/mongodb/mongod.log
it says
2022-02-15T10:42:04.768+0000 E STORAGE [initandlisten] Failed to set up listener: SocketException: Cannot assign requested address
below is my mongod.conf file
(bindIP in the file is set to internal IP for now)
#mongod.conf
#for documentation of all options, see:
#http://docs.mongodb.org/manual/reference/configuration-options/
#Where and how to store data.
storage:
dbPath: /mnt/mongodb/db
journal:
enabled: true
#engine:
#mmapv1:
#wiredTiger:
#where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
#network interfaces
#MongoDB 3.0.x *debian* packages set bind_ip to 127.0.0.1 by default
#Compute Engine public addresses are properly firewalled by default
#set bind_ip to 0.0.0.0 to emulate pre-2.6 behavior which eases
maintenance
net:
port: 27017
bindIp: 10.172.0.5
#processManagement:
security:
authorization: enabled
#keyFile: replace_me
#operationProfiling:
replication:
replSetName: rs0
#sharding:
#Enterprise-Only Options:
#auditLog:
#snmp:
My Answer:
It looks like the issue is related to the bindIP configuration in the mongod.conf file. When you change the bindIP from 0.0.0.0 to the external IP of the MongoDB VM instance, the MongoDB service is unable to start because it cannot assign the requested address.
To resolve this issue, you should set the bindIp to the internal IP of the MongoDB VM instance instead of the external IP. This will allow MongoDB to listen on the internal network interface and communicate with your PHP application deployed on Google App Engine.
Here is the updated bindIp configuration in your mongod.conf file:
net:
port: 27017
bindIp: 10.172.0.5
After making this change, save the mongod.conf file and restart the MongoDB service. Check the status of the service to ensure that it is running successfully.
sudo systemctl restart mongod
sudo systemctl status mongod
This should resolve the issue and allow MongoDB to start successfully with the updated bindIp configuration.
Rate this post
5 of 5 based on 1690 votesComments