mongos, unlike mongod, does not allow listening on an arbitrary OS-assigned port by specifying --port 0.
In ancient times (2010), validation for --port was added to the server.
Then, in slightly less ancient times (2013), this validation was split into separate validation code for mongod and mongos.
And then, in not-even-all-that-long-ago times (2017), the validation for mongod was updated to allow port 0, but no such update was done for the corresponding mongos argument validation.
We should apply that update there as well.
- related to
-
SERVER-78520 Make mongo servers use a file handle to accept new connections
- Backlog