Whenever I run the following command inside the server this works:
mongosh --authenticationDatabase admin --username admin --password password123
But on my PC, I try to connect to the same server with the following
mongosh --host [server ip] --port 27017 --authenticationDatabase admin --username admin --password password123
and this doesn’t work MongoServerError: Authentication failed, I’ve already checked my firewall and everything seems okay, port 27017 is open both udp and tcp, this has been bugging me out since yesterday, what could be causing this?
chris
(Chris Dellaway)
July 30, 2023, 6:59pm
2
Hi @Saylent_N_A , welcome to the forums.
Server logging should also show any failure reasons, search/filter on "c":"ACCESS".
A user can be created to include extra authentication restrictions on the client ip address(es) and server ip address(es).
Use the db.getUser('username', {showAuthenticationRestrictions:true}).authenticationRestrictions command to list any.
// example
db.getUser('foo',{showAuthenticationRestrictions:1}).authenticationRestrictions
[ { clientSource: [ '127.0.0.1/8', '192.168.1.1/24' ] } ]
Another possibility us that the port is being forwarded to another mongodb instance?
2 Likes
system
(system)
Closed
August 26, 2023, 2:54pm
3
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.