Using different port with mongosh

Hi, I installed Mongodb 7. When I try to connect to a different port it is not working. I was wondering if you can help me with this. Here is the example: mongosh --port 28015

Current Mongosh Log ID: 6505ba1b299d74abb10b364c
Connecting to: mongodb://127.0.0.1:28015/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.10.6
MongoNetworkError: connect ECONNREFUSED 127.0.0.1:28015

Looks fine.

The problem appears to be there is no server listening on that address:port.

many thanks for your quick reply. I first used >mongod --port 27000
And it seems that mongod can not connect to the port. here is part of the output:
cache for shutdown"}
{“t”:{“$date”:“2023-09-16T11:30:44.011-04:00”},“s”:“I”, “c”:“CONTROL”, “id”:20565, “ctx”:“initandlisten”,“msg”:“Now exiting”}
{“t”:{“$date”:“2023-09-16T11:30:44.012-04:00”},“s”:“I”, “c”:“CONTROL”, “id”:23138, “ctx”:“initandlisten”,“msg”:“Shutting down”,“attr”:{“exitCode”:100}}

C:\Users\faghihi>

Not enough there to tell why that exited, it might be further back in the log file.

Lines with "s":"E" or "s":"F" are good bet.

As there is no dbpath on the command line the default will be used(\data\db), if there is no directory or adequte permisssions to it that could explain why.

I did restart the computer and weirdly it is working. Thank you so much for your help!!!

1 Like