简体   繁体   中英

Connection to MongoDb server hosted on CentOS is failing

Mongo up and running on CentOs Machine

All IPs enabled, no authorization

# network interfaces
net:
  port: 27017
  bindIp: 0.0.0.0

# security: none
# authorization: 'enabled

Port enabled

netstat -tulnp
(No info could be read for "-p": geteuid()=1001 but you should be root.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:27017           0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN      -

Connection from the server itself using the IP works fine

mongo --host 10.X.X.16
MongoDB shell version v4.2.2
connecting to: mongodb://10.X.X.16:27017/?compressors=disabled&gssapiServiceName=mongodb
MongoDB server version: 4.2.2
Server has startup warnings:
2020-01-21T15:48:26.297-0800 I  CONTROL  [initandlisten]

Doing the same thing from a remote Windows Machine

mongo --host 10.X.X.16
MongoDB shell version v4.2.1
connecting to: mongodb://10.X.X.16:27017/?compressors=disabled&gssapiServiceName=mongodb
2020-01-21T15:59:07.563-0800 E  QUERY    [js] Error: couldn't connect to server 10.65.5.16:27017, connection attempt failed: NetworkTimeout: Error connecting to 10.X.X.16:27017 :: caused by :: Socket operation timed out :
connect@src/mongo/shell/mongo.js:341:17
@(connect):2:6
2020-01-21T15:59:07.571-0800 F  -        [main] exception: connect failed
2020-01-21T15:59:07.571-0800 E  -        [main] exiting with code 1

Thanks!

Problem fixed:

I had to disable the firewall for the mongo port

sudo firewall-cmd --zone=public --add-port=27017/tcp --permanent
sudo firewall-cmd --reload

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