2

I've installed the mongodb in one of my GCE machine. I'm having problem connecting to mongodb from remote machine(i.e. Home Computer).

With Google search I found, I have to bind the right ip address and need to add respective firewall rules, After doing so, Still not able to connect.

Is there any way to connect from my remote machine to access mongodb database ?

Attaching mongodb.conf and firewall rule

#mongodb.conf file    
dbpath=/var/lib/mongodb
logpath=/var/log/mongodb/mongodb.log

logappend=true

bind_ip = 0.0.0.0

port = 27017
journal=true

enter image description here

amport
  • 2,966
  • 2
  • 21
  • 34
Kishore Karunakaran
  • 578
  • 1
  • 6
  • 16

2 Answers2

0

Try changing "bind_ip" in mongodb.conf file to your mongo instance ip and try. (i assumed that correct firewall rules are added in the compute engine settings)

Nimesha Kalinga
  • 242
  • 2
  • 16
  • Nope, It's not working. Firewall rule added with this command **sudo gcloud compute firewall-rules create default-allow-mongo --allow tcp:27017 --source-ranges 0.0.0.0/0 --target-tags mongodb --description "Allow mongodb access to all IPs"** – Kishore Karunakaran Oct 10 '18 at 06:55
  • Hi, try using the gui in cloud.google.com to check whether the rule is applied. https://stackoverflow.com/questions/21065922/how-to-open-a-specific-port-such-as-9090-in-google-compute-engine – Nimesha Kalinga Oct 10 '18 at 08:00
  • 2
    I found the solution, Now it's working. The problem is with in the **target tag** which was added when creating the firewall rule. Create the firewall rule for mongodb with **Apply to all** target tag fixed this issue. – Kishore Karunakaran Oct 10 '18 at 09:01
0

The problem is with in the target tag which was added when creating the firewall rule. Create the firewall rule for mongodb with Apply to all target tag fixed this issue.

Jason
  • 552
  • 2
  • 10