In aws ec2, mongodb is not able to start - mongodb

I recently changed Instance type in AWS EC2 and since then mongoDB is not working.
MongoDB shell version v3.4.14
connecting to: mongodb://127.0.0.1:27017
2019-01-16T10:46:38.525+0000 W NETWORK [thread1] Failed to connect to
127.0.0.1:27017, in(checking socket for error after poll), reason:
Connection refused
2019-01-16T10:46:38.525+0000 E QUERY [thread1] Error: couldn't
connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:240:13
#(connect):1:6
exception: connect failed
mongod.log:
2019-01-16T09:21:17.579+0000 I - [conn21] end connection
127.0.0.1:35148 (20 connections now open) 2019-01-16T09:21:17.579+0000 I - [conn22] end connection 13.127.210.134:42626 (19
connections now open) 2019-01-16T09:21:17.579+0000 I - [conn20]
end connection 127.0.0.1:35146 (18 connections now open)
2019-01-16T09:21:17.579+0000 I - [conn19] end connection
13.127.210.134:42620 (17 connections now open) 2019-01-16T09:21:17.654+0000 I - [conn18] AssertionException
handling request, closing client connection: 6 socket exception
[SEND_ERROR] for 127.0.0.1:35140 2019-01-16T09:21:17.655+0000 I -
[conn18] end connection 127.0.0.1:35140 (16 connections now open)
2019-01-16T09:21:19.408+0000 I ASIO
[NetworkInterfaceASIO-Replication-0] Connecting to
mdb2.thethingscloud.com:27017 2019-01-16T09:21:19.409+0000 I ASIO
[NetworkInterfaceASIO-Replication-0] Failed to connect to
mdb2.thethingscloud.com:27017 - HostUnreachable: Connection refused
2019-01-16T09:21:19.409+0000 I ASIO
[NetworkInterfaceASIO-Replication-0] Dropping all pooled connections
to mdb2.thethingscloud.com:27017 due to failed operation on a
connection 2019-01-16T09:21:19.409+0000 I REPL
[ReplicationExecutor] Error in heartbeat re

Related

Mongodb not connecting after insert with python

Im making a python API and making some inserts , suddenly i cant connect to mongo anymore
MongoDB shell version v3.6.3
connecting to: mongodb://127.0.0.1:27017
2018-07-19T07:16:16.067-0300 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2018-07-19T07:16:16.068-0300 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:251:13
#(connect):1:6
exception: connect failed
Any idea on what could be causing this? my ubuntu

MongoDB shell version v3.6.4

MongoDB shell version v3.6.4
connecting to: mongodb://127.0.0.1:27017
2018-09-25T10:40:02.677+0530 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017 after 5000ms milliseconds, giving up.
2018-09-25T10:40:02.677+0530 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:251:13
#(connect):1:6
exception: connect failed

Cannot connect to mongodb atlas through mongo shell

I've checked other similar posts but none worked for my case.
I upgraded my mongo shell right before connecting to MongoDB Atlas, from which I created a free sandbox database. I used this following for my connection, which was given by atlas.
mongo "mongodb+srv://cluster0-z2lf6.mongodb.net/test" --authenticationDatabase admin --username <user> --password <password>
image of the user of database:
screenshot of the overview of the database:
These are the detail of database:
However, the terminal displays this (I only included about 15 lines, the rest are repetitions.):
MongoDB shell version v3.6.0
connecting to: mongodb+srv://cluster0-z2lf6.mongodb.net/test
2017-12-24T14:39:42.806+0800 I NETWORK [thread1] Starting new replica set monitor for Cluster0-shard-0/cluster0-shard-00-00-z2lf6.mongodb.net.:27017,cluster0-shard-00-01-z2lf6.mongodb.net.:27017,cluster0-shard-00-02-z2lf6.mongodb.net.:27017
2017-12-24T14:39:42.990+0800 W NETWORK [ReplicaSetMonitor-TaskExecutor-0] Failed to connect to 34.232.245.97:27017, in(checking socket for error after poll), reason: Connection refused
2017-12-24T14:39:42.991+0800 W NETWORK [thread1] Failed to connect to 35.168.27.238:27017, in(checking socket for error after poll), reason: Connection refused
2017-12-24T14:39:43.492+0800 W NETWORK [ReplicaSetMonitor-TaskExecutor-0] Failed to connect to 52.20.90.64:27017, in(checking socket for error after poll), reason: Connection refused
2017-12-24T14:39:43.492+0800 W NETWORK [ReplicaSetMonitor-TaskExecutor-0] Unable to reach primary for set Cluster0-shard-0
2017-12-24T14:39:43.492+0800 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Cannot reach any nodes for set Cluster0-shard-0. Please check network connectivity and the status of the set. This has happened for 1 checks in a row.
2017-12-24T14:39:43.997+0800 W NETWORK [thread1] Failed to connect to 35.168.27.238:27017, in(checking socket for error after poll), reason: Connection refused
2017-12-24T14:39:44.000+0800 W NETWORK [thread1] Failed to connect to 34.232.245.97:27017, in(checking socket for error after poll), reason: Connection refused
2017-12-24T14:39:44.003+0800 W NETWORK [thread1] Failed to connect to 52.20.90.64:27017, in(checking socket for error after poll), reason: Connection refused
2017-12-24T14:39:44.004+0800 W NETWORK [thread1] Unable to reach primary for set Cluster0-shard-0
2017-12-24T14:39:44.004+0800 I NETWORK [thread1] Cannot reach any nodes for set Cluster0-shard-0. Please check network connectivity and the status of the set. This has happened for 2 checks in a row.
What could be the reason for this connection error?
In my case reason was that provider changed my ip address (I have dynamic ip, behind NAT)
after I've updated ip whitelist, connection was restored
Actually the reason why I couldn't connect is because I had a network restriction from my university's wifi. I was given a test url http://portquiz.net:27017 from MongoDB's support team, I opened it in a browser and I couldn't access it.
I changed to another place with wifi and it worked.
The new atlas ui - please note that for better security you should not use 0.0.0.0/0 nut your own ip address or use available timer to terminate the rule

mongodb atlas connection issues with ssl

I've created a cluster using mongodb atlas. But, I couldn't connect to that using local mongo shell.
When I use the below connection string, it says --ssl unrecognized.
Harshavardhans-MacBook-Pro:bin harshavmb$ mongo "mongodb://m123-rs1-shard-00-00-wn1jr.mongodb.net:27017,m123-rs1-shard-00-01-wn1jr.mongodb.net:27017,m123-rs1-shard-00-02-wn1jr.mongodb.net:27017/test?replicaSet=m123-rs1-shard-0" --authenticationDatabase admin --ssl --username mongoadmin --password *****
Error parsing command line: unrecognised option '--ssl'
try 'mongo --help' for more information
If I remove --ssl and try, I see the below o/p.
Harshavardhans-MacBook-Pro:bin harshavmb$ mongo "mongodb://m123-rs1-shard-00-00-wn1jr.mongodb.net:27017,m123-rs1-shard-00-01-wn1jr.mongodb.net:27017,m123-rs1-shard-00-02-wn1jr.mongodb.net:27017/test?replicaSet=m123-rs1-shard-0" --authenticationDatabase admin --username mongoadmin --password ****
MongoDB shell version: 3.2.10
connecting to: mongodb://m123-rs1-shard-00-00-wn1jr.mongodb.net:27017,m123-rs1-shard-00-01-wn1jr.mongodb.net:27017,m123-rs1-shard-00-02-wn1jr.mongodb.net:27017/test?replicaSet=m123-rs1-shard-0
2017-03-18T14:19:00.820+0530 I NETWORK [thread1] Starting new replica set monitor for m123-rs1-shard-0/m123-rs1-shard-00-00-wn1jr.mongodb.net:27017,m123-rs1-shard-00-01-wn1jr.mongodb.net:27017,m123-rs1-shard-00-02-wn1jr.mongodb.net:27017
2017-03-18T14:19:00.820+0530 I NETWORK [ReplicaSetMonitorWatcher] starting
2017-03-18T14:19:06.255+0530 I NETWORK [thread1] Socket recv() timeout 35.167.185.140:27017
2017-03-18T14:19:06.258+0530 I NETWORK [thread1] SocketException: remote: (NONE):0 error: 9001 socket exception [RECV_TIMEOUT] server [35.167.185.140:27017]
2017-03-18T14:19:07.040+0530 I NETWORK [thread1] Socket recv() errno:54 Connection reset by peer 35.162.95.185:27017
2017-03-18T14:19:07.040+0530 I NETWORK [thread1] SocketException: remote: (NONE):0 error: 9001 socket exception [RECV_ERROR] server [35.162.95.185:27017]
2017-03-18T14:19:07.757+0530 I NETWORK [thread1] Socket recv() errno:54 Connection reset by peer 35.162.83.174:27017
2017-03-18T14:19:07.757+0530 I NETWORK [thread1] SocketException: remote: (NONE):0 error: 9001 socket exception [RECV_ERROR] server [35.162.83.174:27017]
2017-03-18T14:19:07.757+0530 W NETWORK [thread1] No primary detected for set m123-rs1-shard-0
2017-03-18T14:19:08.985+0530 I NETWORK [thread1] Socket recv() errno:54 Connection reset by peer 35.162.95.185:27017
2017-03-18T14:19:08.985+0530 I NETWORK [thread1] SocketException: remote: (NONE):0 error: 9001 socket exception [RECV_ERROR] server [35.162.95.185:27017]
2017-03-18T14:19:09.702+0530 I NETWORK [thread1] Socket recv() errno:54 Connection reset by peer 35.162.83.174:27017
2017-03-18T14:19:09.702+0530 I NETWORK [thread1] SocketException: remote: (NONE):0 error: 9001 socket exception [RECV_ERROR] server [35.162.83.174:27017]
2017-03-18T14:19:10.419+0530 I NETWORK [thread1] Socket recv() errno:54 Connection reset by peer 35.167.185.140:27017
2017-03-18T14:19:10.419+0530 I NETWORK [thread1] SocketException: remote: (NONE):0 error: 9001 socket exception [RECV_ERROR] server [35.167.185.140:27017]
2017-03-18T14:19:10.419+0530 W NETWORK [thread1] No primary detected for set m123-rs1-shard-0
2017-03-18T14:19:11.648+0530 I NETWORK [ReplicaSetMonitorWatcher] Socket recv() errno:54 Connection reset by peer 35.162.95.185:27017
2017-03-18T14:19:11.648+0530 I NETWORK [thread1] Socket recv() errno:54 Connection reset by peer 35.167.185.140:27017
2017-03-18T14:19:11.648+0530 I NETWORK [ReplicaSetMonitorWatcher] SocketException: remote: (NONE):0 error: 9001 socket exception [RECV_ERROR] server [35.162.95.185:27017]
2017-03-18T14:19:11.648+0530 I NETWORK [thread1] SocketException: remote: (NONE):0 error: 9001 socket exception [RECV_ERROR] server [35.167.185.140:27017]
2017-03-18T14:19:12.364+0530 I NETWORK [ReplicaSetMonitorWatcher] Socket recv() errno:54 Connection reset by peer 35.162.83.174:27017
2017-03-18T14:19:12.365+0530 I NETWORK [ReplicaSetMonitorWatcher] SocketException: remote: (NONE):0 error: 9001 socket exception [RECV_ERROR] server [35.162.83.174:27017]
2017-03-18T14:19:12.365+0530 W NETWORK [ReplicaSetMonitorWatcher] No primary detected for set m123-rs1-shard-0
2017-03-18T14:19:14.731+0530 I NETWORK [thread1] Socket recv() errno:54 Connection reset by peer 35.162.83.174:27017
2017-03-18T14:19:14.731+0530 I NETWORK [thread1] SocketException: remote: (NONE):0 error: 9001 socket exception [RECV_ERROR] server [35.162.83.174:27017]
2017-03-18T14:19:14.731+0530 W NETWORK [thread1] No primary detected for set m123-rs1-shard-0
2017-03-18T14:19:15.845+0530 I NETWORK [thread1] Socket recv() errno:54 Connection reset by peer 35.162.95.185:27017
2017-03-18T14:19:15.845+0530 I NETWORK [thread1] SocketException: remote: (NONE):0 error: 9001 socket exception [RECV_ERROR] server [35.162.95.185:27017]
2017-03-18T14:19:16.563+0530 I NETWORK [thread1] Socket recv() errno:54 Connection reset by peer 35.167.185.140:27017
2017-03-18T14:19:16.563+0530 I NETWORK [thread1] SocketException: remote: (NONE):0 error: 9001 socket exception [RECV_ERROR] server [35.167.185.140:27017]
2017-03-18T14:19:17.176+0530 I NETWORK [thread1] Socket recv() errno:54 Connection reset by peer 35.162.83.174:27017
2017-03-18T14:19:17.177+0530 I NETWORK [thread1] SocketException: remote: (NONE):0 error: 9001 socket exception [RECV_ERROR] server [35.162.83.174:27017]
2017-03-18T14:19:17.177+0530 W NETWORK [thread1] No primary detected for set m123-rs1-shard-0
2017-03-18T14:19:17.181+0530 E QUERY [thread1] Error: connect failed to replica set m123-rs1-shard-0/m123-rs1-shard-00-00-wn1jr.mongodb.net:27017,m123-rs1-shard-00-01-wn1jr.mongodb.net:27017,m123-rs1-shard-00-02-wn1jr.mongodb.net:27017 :
connect#src/mongo/shell/mongo.js:223:14
#(connect):1:6
exception: connect failed
Interestingly, I was able to connect to the cluster with java driver. Only shell has this problem.
Have googled a lot to find fix this ssl issue, but couldn't find any helpful link.
Any help would be highly appreciated.
Thanks in advance.
Error parsing command line: unrecognised option '--ssl' try 'mongo --help' for more information
MongoDB Atlas requires SSL/TLS for all connections. This command-line error indicates your version of the mongo shell does not include SSL/TLS support.
Depending on your preference, you can install an appropriate mongo shell version using:
Homebrew: brew install mongodb --with-openssl.
MongoDB Download Center. Note: the default should be to download binaries w/ SSL support, but there are non-SSL downloads available in the dropdown list as well.
It's generally better to install a packaged version (eg. Homebrew) as this simplifies the process of managing the mongod service and updating to new releases. The binary downloads may be more relevant if you want to run multiple versions of MongoDB or keep files isolated to a specific directory, but do not include conveniences like a service wrapper or default config file.
You have to have mongodb with SSL/TSL because MongoDB Atlas needs it for all connections.
You can get by running following command.
brew install mongodb --with-openssl
And upgrade your mongodb to 3.4.4.
brew upgrade mongodb
Then try connecting to mongo cloud via mongo shell.
Recently MongoDb Atlas switched their certificates from Digicert to LetsEncrypt (Feb 2020), and it may have issues for certificate stores that don't have the LetsEncrypt ones it in.
A temporary bypass is to include sslVerifyCertificate=false on the end of a connection string. But the solution is to update your OS or driver libraries to have a version that includes the LetsEncrypt certificates.
I had copied Mongo 3.2 binaries to /usr/local/bin directory, so this wasn't allowing newer version of mongo binaries (3.4). So, eventually I had to remove the binaries from /usr/local/bin directory and paste the binaries of 3.4 and this fixed the ssl issue.

stuck of start mongoDB

2017-03-01T00:51:32.863-0500 I CONTROL [initandlisten]
2017-03-01T00:51:33.271-0500 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory 'D:/mongo/data/diagnostic.data'
2017-03-01T00:51:33.284-0500 I NETWORK [thread1] waiting for connections on port 27017
2017-03-01T00:51:33.391-0500 I NETWORK [thread1] connection accepted from 127.0.0.1:50501 #1 (1 connection now open)
2017-03-01T00:51:33.394-0500 I NETWORK [thread1] connection accepted from 127.0.0.1:50502 #2 (2 connections now open)
2017-03-01T00:51:33.399-0500 I NETWORK [thread1] connection accepted from 127.0.0.1:50503 #3 (3 connections now open)
2017-03-01T00:51:33.401-0500 I NETWORK [thread1] connection accepted from 127.0.0.1:50504 #4 (4 connections now open)
2017-03-01T00:51:33.406-0500 I NETWORK [thread1] connection accepted from 127.0.0.1:50505 #5 (5 connections now open)
2017-03-01T00:51:33.418-0500 I NETWORK [thread1] connection accepted from 127.0.0.1:50506 #6 (6 connections now open)
When I start the mongoDB, the command line pop up these things, how could I fix it? I have tried delete the data folder...