Google Cloud Platform - Can't connect to mongodb

后端 未结 5 1147
夕颜
夕颜 2020-12-20 14:53

Just installed mongodb using click-to-deploy in google cloud platform. I have another project, for which I created the mongodb database, where my web application runs. Do I

相关标签:
5条回答
  • 2020-12-20 15:16

    This answer explains how to set the firewall rule for port 27017.

    Another issue that could cause this is running your mongodb in a separate network and having your other instances on the default network (or vice versa).

    I ran into this and after getting both instances on the same network, it was able to connect to the mongo instance by name.

    Here's an example of how to set the network for a managed VM in your app.yaml:

    network:
      instance_tag: https-server
      name: my-node-network
    
    0 讨论(0)
  • 2020-12-20 15:30

    Adding the port in the firewall is not enough. By default the host bind to 127.0.0.1 which needs to be changed to 0.0.0.0 Make changes in the file sudo nano /etc/mongod.conf inside the instance Look for the term bindIp change it to 0.0.0.0 and restart mongodb You will be able to connect to the mongo db now

    0 讨论(0)
  • 2020-12-20 15:31

    On the Mongodb project you should open firewall for port 27017.

    MongoDB used ports are listed at:
    http://docs.mongodb.org/manual/tutorial/configure-linux-iptables-firewall/

    Regards,
    Paolo

    0 讨论(0)
  • 2020-12-20 15:34

    Click on the Http or Https checkbox to activate the external ip address so u can use it to access the database

    0 讨论(0)
  • 2020-12-20 15:42

    As the other answers in this thread suggest, mongod daemon is listening on TCP port 27017. Therefore, you will need to add a firewall rule on Compute Engine firewall for this port and protocol. This can be done using Google Cloud console or using gcloud command tool:

    gcloud compute firewall-rules create allow-mongodb --allow tcp:27017
    

    It is recommended to use target tag with the firewall rule and use this target tag to specify what VM instances the firewall rule should be applied to.

    0 讨论(0)
提交回复
热议问题