简体   繁体   中英

How to make Mongodb 27017 port available on Ubuntu

After installing and starting mongodb on Google Ubuntu instance I can verify that 'mongodb' is running with: sudo systemctl status mongodb :

● mongodb.service - LSB: An object/document-oriented database
   Loaded: loaded (/etc/init.d/mongodb; generated; vendor preset: enabled)
   Active: active (running) since Mon 2017-02-27 19:41:17 UTC; 57min ago
     Docs: man:systemd-sysv-generator(8)
    Tasks: 13 (limit: 4915)
   Memory: 71.7M
      CPU: 14.520s
   CGroup: /system.slice/mongodb.service
           └─1914 /usr/bin/mongod --config /etc/mongodb.conf
Feb 27 19:41:15 instance-1 systemd[1]: Starting LSB: An object/document-oriented database...
Feb 27 19:41:16 instance-1 mongodb[1827]:  * Starting database mongodb
Feb 27 19:41:17 instance-1 mongodb[1827]:    ...done.
Feb 27 19:41:17 instance-1 systemd[1]: Started LSB: An object/document-oriented database.

It all looks good. But by some reason another application running on the same machine is not able to connect to the what-seems-to-be-running-properly mongodb .

Running nmap 127.0.0.1 returns:

PORT    STATE SERVICE
22/tcp  open  ssh
631/tcp open  ipp

There is no mongodb's port # 27017 listed there as *open*. Interesting that the firewall is disabled. How can I assure the mongodb's port # 27017 listed there as *open*. Interesting that the firewall is disabled. How can I assure the mongodb's port # 27017 listed there as *open*. Interesting that the firewall is disabled. How can I assure the mongodb port 27017` is open and available to other applications?

nmap scan all common port, mongodb use port 27017 by default which is not listed in default nmap default port scan. On the other hand, you can specify the port manually :

nmap -p 27017  127.0.0.1

You will get :

PORT      STATE SERVICE
27017/tcp open  unknown

If you see STATE close, this means mongodb is not running and then you should begin to worry about it

Or as suggested by @Dimitri using netstat such as :

netstat -tulpn

which gives :

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:27017         0.0.0.0:*               LISTEN      -               

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM