Failed to connect to a.b.c.d:27017, in(checking socket for error after poll), reason: Connection refused
I have mongo 3.4 and I have generated my pem files for client and server and below command is starting my mongoDB:
sudo mongod --port 27017 --dbpath /var/lib/mongodb --sslMode requireSSL --sslPEMKeyFile /etc/ssl/mongo_ssl/server.pem
I am able to connect to the DB by following command:
mongo --ssl --sslPEMKeyFile client.pem --sslCAFile ca.cert --host akshay.abc.com
I have used the below command to generate my certs:
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
Below is my mongod.conf file:
# 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:
Service is running fine but when I now connect it with mongo command which I used earlier it is giving me the below error:
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
Can anyone point me in the right direction?
sudo mongod
Is this for the Docker image?
You could try asking Docker Community Forums, Docker Community Slack, or Stack Overflow. Unless there's something missing in the image that should be there