Is it true that by default mongos and mongod use the same port - 27017?
I had to pick a different port for one of these two, for example
--port 37017 for mongos.
Yes, they have the same default port. Generally, the most common production set up is to have the
mongos running on the application server, not the same host as the mongod, hence it is rare for this to cause a problem once you go beyond a development environment - if you are running a replica set on a single host for testing you similarly have to alter the ports for each
There are a few reasons to run as you suggest (security policy, certain data distribution patterns), but as you have discovred, if you alter the port appropriately there is no issue running
mongod on the same host.