Unable to connect to mongo on remote server

前端 未结 5 1716
闹比i
闹比i 2021-02-05 10:17

I have installed mongo on machine1(Ubuntu 14.04.3 LTS server) in my local network. I have also opened the port 27017 as mentioned in this guide using f

相关标签:
5条回答
  • 2021-02-05 10:39

    Make sure you have a daemon running on your machine1 which listen to port 27017. We were getting the same error and found that daemon was not running.

    0 讨论(0)
  • 2021-02-05 10:40

    I have tried a different way to solve this issue. I have changed the config file from

    bind_ip = 127.0.0.1
    #port = 27017
    

    to

    bind_ip = 0.0.0.0
    #port = 27017
    

    Hope it helps. Happy coding ;)

    0 讨论(0)
  • 2021-02-05 10:41

    The issue was bindIp didn't change. There was some issue in restarting mongo from my side.

    The habit should be to verify if the bindIp actually changed or not. (using sudo netstat -tulpn | grep 27017)

    0 讨论(0)
  • 2021-02-05 10:56

    make sure that mongodb daemon is running, and listening on 0.0.0.0, but not 127.0.0.1 port

    for example, for my local mongodb, it has this config:

    [vodolaz095@steel ~]$ cat /etc/mongod.conf 
    ##
    ### Basic Defaults
    ##
    
    # Comma separated list of ip addresses to listen on (all local ips by default)
    bind_ip = 127.0.0.1
    
    # Specify port number (27017 by default)
    #port = 27017
    

    for mongodb server to listen for remote connections, you can change

    # Comma separated list of ip addresses to listen on (all local ips by default)
    bind_ip = 0.0.0.0
    
    0 讨论(0)
  • 2021-02-05 10:58

    With mongoDB server version 3.6.4, Ubuntu 16.4.4 I solved this by setting the net section in /etc/mongod.conf like this:

    net:
      port: 27017
      bindIpAll: true
    #  bindIp: 127.0.0.1
    
    0 讨论(0)
提交回复
热议问题