Connection refused problem

Hi…After I add node4 and arbiter to my replica set, I get the following error message…“2019-12-29T06:51:19.832+0000 W NETWORK [ReplicaSetMonitor-TaskExecutor-0] Failed to connect to 127.0.0.1:27014, in(checking socket for error after poll), reason: Connection refused”. I got the same error message while creating replica set first time. Then I changed 127.0.1.1 to 127.0.0.1 in my /etc/hosts file. But I still get this message.

Let’s see a screenshot of your /etc/hosts file

Yes please…

Update your hosts file following the advice in this post.

After update my hosts file, I still get this error message
hosts2

Yeah, don’t worry. The etc file wasn’t related to this error, but it will fix another issue you would have faced in the future.

Let’s see the outputs of the following:
ps -ef | grep [m]ongo
rs.status()
rs.config()

This is what I get…
ps -ef | grep [m]ongo
vagrant 2154 1 3 07:45 ? 00:00:57 mongod -f mongod-repl-1.conf
vagrant 2236 1 3 07:45 ? 00:00:55 mongod -f mongod-repl-2.conf
vagrant 2323 1 3 07:45 ? 00:00:55 mongod -f mongod-repl-3.conf
rs.status()
MongoDB Enterprise m103-repl:PRIMARY> rs.status()
{
“set” : “m103-repl”,
“date” : ISODate(“2019-12-29T08:05:07.254Z”),
“myState” : 1,
“term” : NumberLong(6),
“syncingTo” : “”,
“syncSourceHost” : “”,
“syncSourceId” : -1,
“heartbeatIntervalMillis” : NumberLong(2000),
“optimes” : {
“lastCommittedOpTime” : {
“ts” : Timestamp(1577606699, 1),
“t” : NumberLong(6)
},
“readConcernMajorityOpTime” : {
“ts” : Timestamp(1577606699, 1),
“t” : NumberLong(6)
},
“appliedOpTime” : {
“ts” : Timestamp(1577606699, 1),
“t” : NumberLong(6)
},
“durableOpTime” : {
“ts” : Timestamp(1577606699, 1),
“t” : NumberLong(6)
}
},
“members” : [
{
“_id” : 0,
“name” : “192.168.103.100:27001”,
“health” : 1,
“state” : 1,
“stateStr” : “PRIMARY”,
“uptime” : 1200,
“optime” : {
“ts” : Timestamp(1577606699, 1),
“t” : NumberLong(6)
},
“optimeDate” : ISODate(“2019-12-29T08:04:59Z”),
“syncingTo” : “”,
“syncSourceHost” : “”,
“syncSourceId” : -1,
“infoMessage” : “”,
“electionTime” : Timestamp(1577605567, 1),
“electionDate” : ISODate(“2019-12-29T07:46:07Z”),
“configVersion” : 5,
“self” : true,
“lastHeartbeatMessage” : “”
},
{
“_id” : 1,
“name” : “m103:27002”,
“health” : 1,
“state” : 2,
“stateStr” : “SECONDARY”,
“uptime” : 1166,
“optime” : {
“ts” : Timestamp(1577606699, 1),
“t” : NumberLong(6)
},
“optimeDurable” : {
“ts” : Timestamp(1577606699, 1),
“t” : NumberLong(6)
},
“optimeDate” : ISODate(“2019-12-29T08:04:59Z”),
“optimeDurableDate” : ISODate(“2019-12-29T08:04:59Z”),
“lastHeartbeat” : ISODate(“2019-12-29T08:05:05.854Z”),
“lastHeartbeatRecv” : ISODate(“2019-12-29T08:05:05.855Z”),
“pingMs” : NumberLong(2),
“lastHeartbeatMessage” : “”,
“syncingTo” : “192.168.103.100:27001”,
“syncSourceHost” : “192.168.103.100:27001”,
“syncSourceId” : 0,
“infoMessage” : “”,
“configVersion” : 5
},
{
“_id” : 2,
“name” : “m103:27003”,
“health” : 1,
“state” : 2,
“stateStr” : “SECONDARY”,
“uptime” : 1144,
“optime” : {
“ts” : Timestamp(1577606699, 1),
“t” : NumberLong(6)
},
“optimeDurable” : {
“ts” : Timestamp(1577606699, 1),
“t” : NumberLong(6)
},
“optimeDate” : ISODate(“2019-12-29T08:04:59Z”),
“optimeDurableDate” : ISODate(“2019-12-29T08:04:59Z”),
“lastHeartbeat” : ISODate(“2019-12-29T08:05:05.853Z”),
“lastHeartbeatRecv” : ISODate(“2019-12-29T08:05:06.273Z”),
“pingMs” : NumberLong(0),
“lastHeartbeatMessage” : “”,
“syncingTo” : “192.168.103.100:27001”,
“syncSourceHost” : “192.168.103.100:27001”,
“syncSourceId” : 0,
“infoMessage” : “”,
“configVersion” : 5
},
{
“_id” : 3,
“name” : “m103.mongodb.university:27014”,
“health” : 0,
“state” : 8,
“stateStr” : “(not reachable/healthy)”,
“uptime” : 0,
“optime” : {
“ts” : Timestamp(0, 0),
“t” : NumberLong(-1)
},
“optimeDurable” : {
“ts” : Timestamp(0, 0),
“t” : NumberLong(-1)
},
“optimeDate” : ISODate(“1970-01-01T00:00:00Z”),
“optimeDurableDate” : ISODate(“1970-01-01T00:00:00Z”),
“lastHeartbeat” : ISODate(“2019-12-29T08:05:06.164Z”),
“lastHeartbeatRecv” : ISODate(“1970-01-01T00:00:00Z”),
“pingMs” : NumberLong(0),
“lastHeartbeatMessage” : “Connection refused”,
“syncingTo” : “”,
“syncSourceHost” : “”,
“syncSourceId” : -1,
“infoMessage” : “”,
“configVersion” : -1
},
{
“_id” : 4,
“name” : “m103.mongodb.university:28000”,
“health” : 0,
“state” : 8,
“stateStr” : “(not reachable/healthy)”,
“uptime” : 0,
“lastHeartbeat” : ISODate(“2019-12-29T08:05:06.496Z”),
“lastHeartbeatRecv” : ISODate(“1970-01-01T00:00:00Z”),
“pingMs” : NumberLong(0),
“lastHeartbeatMessage” : “Connection refused”,
“syncingTo” : “”,
“syncSourceHost” : “”,
“syncSourceId” : -1,
“infoMessage” : “”,
“configVersion” : -1
}
],
“ok” : 1,
“operationTime” : Timestamp(1577606699, 1),
“$clusterTime” : {
“clusterTime” : Timestamp(1577606699, 1),
“signature” : {
“hash” : BinData(0,“7B/OsiHJwvTJRWHtzb1MCUeMPL0=”),
“keyId” : NumberLong(“6774435032464359425”)
}
}
}

rs.config()
{
“_id” : 0,
“host” : “192.168.103.100:27001”,
“arbiterOnly” : false,
“buildIndexes” : true,
“hidden” : false,
“priority” : 1,
“tags” : {

                    },
                    "slaveDelay" : NumberLong(0),
                    "votes" : 1
            },
            {
                    "_id" : 1,
                    "host" : "m103:27002",
                    "arbiterOnly" : false,
                    "buildIndexes" : true,
                    "hidden" : false,
                    "priority" : 1,
                    "tags" : {

                    },
                    "slaveDelay" : NumberLong(0),
                    "votes" : 1
            },
            {
                    "_id" : 2,
                    "host" : "m103:27003",
                    "arbiterOnly" : false,
                    "buildIndexes" : true,
                    "hidden" : false,
                    "priority" : 1,
                    "tags" : {

                    },
                    "slaveDelay" : NumberLong(0),
                    "votes" : 1
            },
            {
                    "_id" : 3,
                    "host" : "m103.mongodb.university:27014",
                    "arbiterOnly" : false,
                    "buildIndexes" : true,
                    "hidden" : false,
                    "priority" : 1,
                    "tags" : {

                    },
                    "slaveDelay" : NumberLong(0),
                    "votes" : 1
            },
            {
                    "_id" : 4,
                    "host" : "m103.mongodb.university:28000",
                    "arbiterOnly" : true,
                    "buildIndexes" : true,
                    "hidden" : false,
                    "priority" : 0,
                    "tags" : {

                    },
                    "slaveDelay" : NumberLong(0),
                    "votes" : 1
            }
    ],
    "settings" : {
            "chainingAllowed" : true,
            "heartbeatIntervalMillis" : 2000,
            "heartbeatTimeoutSecs" : 10,
            "electionTimeoutMillis" : 10000,
            "catchUpTimeoutMillis" : -1,
            "catchUpTakeoverDelayMillis" : 30000,
            "getLastErrorModes" : {

            },
            "getLastErrorDefaults" : {
                    "w" : 1,
                    "wtimeout" : 0
            },
            "replicaSetId" : ObjectId("5e03a0c4da4011e00954dacb")
    }

}

You should be familiar with rs.status() by now, so have a look through it and you’ll notice that you added some nodes that shouldn’t be there. Once you’ve identified those nodes, use rs.remove() to remove them.

Hi @Anbazhagan,

As @007_jb mentioned, please remove the extra nodes from your replica set.

Connectioin Refused

In addition to that, you have only three mongod instances running while you are having 5 nodes in your replica set.

Thanks,
Shubham Ranjan
Curriculum Support Engineer