无法连接到a.b.c.d:27017,(在轮询后检查套接字是否错误),原因:连接被拒绝

时间:2019-07-03 10:40:28

标签: mongodb mongoose

我有mongo 3.4,并且已经为客户端和服务器生成了我的pem文件,并且以下命令正在启动我的mongoDB:

sudo mongod --port 27017 --dbpath /var/lib/mongodb --sslMode requireSSL --sslPEMKeyFile /etc/ssl/mongo_ssl/server.pem

我可以通过以下命令连接到数据库:

mongo --ssl --sslPEMKeyFile client.pem --sslCAFile ca.cert --host akshay.abc.com

我已使用以下命令生成我的证书:

openssl req -newkey rsa:2048 -new  -sha256 -out server.csr -keyout server.key -subj "/C=IN/ST=DELHI/L=DELHI/O=MongoDB/OU=demoservers/CN=akshay.abc.com" -nodes

下面是我的mongod.conf文件:

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# Where and how to store data.
storage:
  dbPath: /var/lib/mongodb
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1
  ssl:
        mode: requireSSL
        PEMKeyFile: /etc/ssl/mongo_ssl/server.pem
        CAFile: /etc/ssl/mongo_ssl/client.pem

#processManagement:

服务运行良好,但是当我现在使用之前使用的mongo命令连接它时,出现以下错误:

2019-07-04T10:32:24.249+0000 W NETWORK  [thread1] Failed to connect to a.b.c.d:27017, in(checking socket for error after poll), reason: Connection refused
2019-07-04T10:32:24.249+0000 E QUERY    [thread1] Error: couldn't connect to server akshay.abc.com:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:240:13
@(connect):1:6
exception: connect failed

有人能指出我正确的方向吗?

0 个答案:

没有答案