Configuring mongodb sharding

So, I was configuring mongodb sharding cluster on multiple servers. I’ve configured a config server and two shard servers. When I try configure mongos router on mongos server with command:

mongos --configdb config/<config-sevrer-ip>:27017 --bind_ip localhost,<mongos-server-ip>

I get an output like this:

{"t":{"$date":"2023-02-27T08:25:41.419Z"},"s":"W",  "c":"SHARDING", "id":24132,   "ctx":"-","msg":"Running a sharded cluster with fewer than 3 config servers should only be done for testing purposes and is not recommended for production."}
{"t":{"$date":"2023-02-27T08:25:41.422+00:00"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2023-02-27T08:25:41.423+00:00"},"s":"I",  "c":"NETWORK",  "id":4915701, "ctx":"main","msg":"Initialized wire specification","attr":{"spec":{"incomingExternalClient":{"minWireVersion":0,"maxWireVersion":17},"incomingInternalClient":{"minWireVersion":0,"maxWireVersion":17},"outgoing":{"minWireVersion":17,"maxWireVersion":17},"isInternalClient":true}}}
{"t":{"$date":"2023-02-27T08:25:41.423+00:00"},"s":"I",  "c":"NETWORK",  "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
{"t":{"$date":"2023-02-27T08:25:41.424+00:00"},"s":"I",  "c":"HEALTH",   "id":5936503, "ctx":"main","msg":"Fault manager changed state ","attr":{"state":"StartupCheck"}}
{"t":{"$date":"2023-02-27T08:25:41.426+00:00"},"s":"W",  "c":"CONTROL",  "id":22120,   "ctx":"main","msg":"Access control is not enabled for the database. Read and write access to data and configuration is unrestricted","tags":["startupWarnings"]}
{"t":{"$date":"2023-02-27T08:25:41.426+00:00"},"s":"I",  "c":"CONTROL",  "id":23403,   "ctx":"mongosMain","msg":"Build Info","attr":{"buildInfo":{"version":"6.0.4","gitVersion":"44ff59461c1353638a71e710f385a566bcd2f547","openSSLVersion":"OpenSSL 3.0.2 15 Mar 2022","modules":[],"allocator":"tcmalloc","environment":{"distmod":"ubuntu2204","distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2023-02-27T08:25:41.427+00:00"},"s":"I",  "c":"CONTROL",  "id":51765,   "ctx":"mongosMain","msg":"Operating System","attr":{"os":{"name":"Ubuntu","version":"22.04"}}}
{"t":{"$date":"2023-02-27T08:25:41.428+00:00"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"mongosMain","msg":"Options set by command line","attr":{"options":{"net":{"bindIp":"localhost,100.25.159.201"},"sharding":{"configDB":"config/54.157.187.130:27017"}}}}
{"t":{"$date":"2023-02-27T08:25:41.429+00:00"},"s":"E",  "c":"SHARDING", "id":22856,   "ctx":"mongosMain","msg":"Error setting up listener","attr":{"error":{"code":9001,"codeName":"SocketException","errmsg":"Cannot assign requested address"}}}
{"t":{"$date":"2023-02-27T08:25:41.429+00:00"},"s":"I",  "c":"COMMAND",  "id":4695701, "ctx":"main","msg":"Entering quiesce mode for mongos shutdown","attr":{"quiesceTimeMillis":15000}}
{"t":{"$date":"2023-02-27T08:25:56.429+00:00"},"s":"I",  "c":"COMMAND",  "id":4695702, "ctx":"main","msg":"Exiting quiesce mode for mongos shutdown"}
{"t":{"$date":"2023-02-27T08:25:56.429+00:00"},"s":"I",  "c":"-",        "id":4695300, "ctx":"main","msg":"Interrupted all currently running operations","attr":{"opsKilled":1}}
{"t":{"$date":"2023-02-27T08:25:59.429+00:00"},"s":"I",  "c":"CONTROL",  "id":23138,   "ctx":"main","msg":"Shutting down","attr":{"exitCode":48}}

I’ve understood that my mongos router can’t assign requested address but I don’t know what I’m doing wrong. I’d be grateful if anyone can help me. I’ve configured the security groups so there is no issue regarding firewall and ports. But still it can’t establish a connection and connection is refused.HELP ME!!!

IP address you are passing for configdb parameter seems to be not correct
Did you try with hostname?
How did you start your config servers?
Show rs.status() of config servers

sure
{ set: 'config', date: ISODate("2023-02-27T11:52:49.851Z"), myState: 1, term: Long("11"), syncSourceHost: '', syncSourceId: -1, configsvr: true, heartbeatIntervalMillis: Long("2000"), majorityVoteCount: 1, writeMajorityCount: 1, votingMembersCount: 1, writableVotingMembersCount: 1, optimes: { lastCommittedOpTime: { ts: Timestamp({ t: 1677498768, i: 1 }), t: Long("11") }, lastCommittedWallTime: ISODate("2023-02-27T11:52:48.993Z"), readConcernMajorityOpTime: { ts: Timestamp({ t: 1677498768, i: 1 }), t: Long("11") }, appliedOpTime: { ts: Timestamp({ t: 1677498768, i: 1 }), t: Long("11") }, durableOpTime: { ts: Timestamp({ t: 1677498768, i: 1 }), t: Long("11") }, lastAppliedWallTime: ISODate("2023-02-27T11:52:48.993Z"), lastDurableWallTime: ISODate("2023-02-27T11:52:48.993Z") }, lastStableRecoveryTimestamp: Timestamp({ t: 1677494104, i: 1 }), electionCandidateMetrics: { lastElectionReason: 'electionTimeout', lastElectionDate: ISODate("2023-02-27T11:52:28.973Z"), electionTerm: Long("11"), lastCommittedOpTimeAtElection: { ts: Timestamp({ t: 0, i: 0 }), t: Long("-1") }, lastSeenOpTimeAtElection: { ts: Timestamp({ t: 1677494104, i: 1 }), t: Long("10") }, numVotesNeeded: 1, priorityAtElection: 1, electionTimeoutMillis: Long("10000"), newTermStartDate: ISODate("2023-02-27T11:52:28.977Z"), wMajorityWriteAvailabilityDate: ISODate("2023-02-27T11:52:28.988Z") }, members: [ { _id: 0, name: '127.0.0.1:27017', health: 1, state: 1, stateStr: 'PRIMARY', uptime: 22, optime: { ts: Timestamp({ t: 1677498768, i: 1 }), t: Long("11") }, optimeDate: ISODate("2023-02-27T11:52:48.000Z"), lastAppliedWallTime: ISODate("2023-02-27T11:52:48.993Z"), lastDurableWallTime: ISODate("2023-02-27T11:52:48.993Z"), syncSourceHost: '', syncSourceId: -1, infoMessage: '', electionTime: Timestamp({ t: 1677498748, i: 1 }), electionDate: ISODate("2023-02-27T11:52:28.000Z"), configVersion: 1, configTerm: 11, self: true, lastHeartbeatMessage: '' } ], ok: 1, lastCommittedOpTime: Timestamp({ t: 1677498768, i: 1 }), '$clusterTime': { clusterTime: Timestamp({ t: 1677498768, i: 1 }), signature: { hash: Binary(Buffer.from("0000000000000000000000000000000000000000", "hex"), 0), keyId: Long("0") } }, operationTime: Timestamp({ t: 1677498768, i: 1 }) }

Try with localhost instead of configserver ip address
–configdb replsetname/localhost:port

No. It cannot be done because the config server is configured on another server and we can only reach it with public ip.

But your rs.status() of config server shows it is configured as localhost(127.0.0.1)
Configure it using hostname/ip and refer the same while starting mongos

I tried that but it was not working then also.