How to fix connection timeout problem with MongoDB

Some of us have encountered a problem problem right after installing MongoDB, turns out we can’t connect. I personally get this: root@ghost:~# mongo MongoDB shell version v4.2.8 connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb 2020-10-30T12:10:51.955+0100 E QUERY [js] Error: couldn’t connect to server 127.0.0.1:27017, connection attempt fa iled: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection timed out : connect@src/mongo/shell/mongo.js:341:17 @(connect):2:6 2020-10-30T12:10:51.958+0100 …

How to list IP tables in Linux

This is helpful for when you can’t access your localhost (127.0.0.1). Specially if you are having trouble accessing MongoDB after installation. Here is the command: iptables -L –line-numbers Sources: https://dba.stackexchange.com/questions/181693/mongodb-exception-connect-failed

How to locally configure a replica set in MongoDB

This post will guide you through the steps to set up a local replica set with two members and one arbiter. In a production environment the steps must be almost the same except that instead of starting three local MongoDB instances in different ports you would start an instance of MongoDB on each server with its own configuration file. This …