Can't connect to mongodb using shell but can connect using compas - mongodb

From the same client, I can connect to my remote mongodb using this string:
mongodb://siteadmin:mypassword#myip:27017
But from the shell when I run
mongo "mongodb://siteadmin:mypassword#myip:27017"
DB.prototype._authOrThrow#src/mongo/shell/db.js:1608:20
#(auth):6:1
#(auth):1:2
exception: login failed
root#shadow:~/website-fron
Any idea?
My config is simple:
security:
authorization: 'enabled'
net:
port: 27017
bindIp: 0.0.0.0

Related

Can't connect to my mongodb localhost after using SSL/TLS certificates

Each time I try connecting to my localhost server using SSL/TLS certificate I get an error which says, connection attempt failed: HostUnreachable
Things I've tried
I've tried restarting my system
I've tried changing the tls to SSL
I've also cross-checked the file path for mongodb.pem,
I'm really at a loss.
This is the code I ran and the error I'm getting
MongoDB shell version v5.0.9
connecting to: mongodb://localhost:27017/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server localhost:27017, connection attempt failed: HostUnreachable: Connection reset by peer :
connect#src/mongo/shell/mongo.js:372:17
#(connect):2:6
exception: connect failed
exiting with code 1
This is my mongo.cfg file
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: C:\Program Files\MongoDB\Server\5.0\data
journal:
enabled: true
# engine:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: C:\Program Files\MongoDB\Server\5.0\log\mongod.log
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1
#processManagement:
security:
authorization: enabled
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
This is the command I used to connect to the server
mongo --tls --tlsCAFile mongodb.pem --host localhost

Connection Problem in mongodb 4.2.8 on AWS ec2

I have created new Instance on AWS ec2 and installed the mongodb 4.2.8 on server but I'm unable to connect with mongodb using local terminal of Ubuntu 18.0.2. I'm hitting a command which will import a mongodb dump database into the server database the command is given below
mongorestore --host IPv4_Public_IP --port 27017 --db db_name dump/dataDb/
The error I'm facing is
error connecting to host: could not connect to server: server selection error: server selection timeout, current topology: { Type: Single, Servers: [{ Addr: IPv4_Public_IP:27017, Type: Unknown, State: Connected, Average RTT: 0, Last error: connection() : dial tcp IPv4_Public_IP:27017: connect: connection refused }, ] }
And how to set the Inboud rules for that instance. For now these are
SSH TCP 22 0.0.0.0/0 -
Custom TCP 27017 my_ip -

Lost connection to MySQL server with Mongo connector

I'm getting the following error when trying to connect to power bi "ODBC: ERROR [08S01] [MySQL][ODBC 1.4(a) Driver]Lost connection to MySQL server at 'waiting for initial communication packet', system error: 10060".
My bi connector is on vm where my mongo server is allocated, I created a service which is running and I have no error logs but I still can't connect using powerbi. This is the mongosqld.conf I'm using
systemLog:
path: '/var/log/mongosqld.log'
net:
bindIp: '127.0.0.1'
port: 3307
mongodb:
net:
uri: 'server_ip'
ssl:
enabled: false
auth:
username: user
password: pwd
security:
enabled: true
What I'm doing wrong?!

Why Mongodb config changes not getting applied?

I am running Mongodb on AWS windows instance, I changed my config setting as following:
net:
port: 30000
bindIp: 0.0.0.0
As far as my knowledge, Server should get started on port 30000, it can listen request from other ip as well
However, on restarting mongod, it is still running on localhost and listening to port 27017
I have the same problem with you. What I did is a workaround it. I start the service with specifying the port and ip.
mongod --auth --port 30000 --dbpath /data/db --bind_ip_all

Can't connect to mongodb running on EC2, Ubuntu 16

This is my mongo.conf
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
net:
port: 27017
bindIp: 0.0.0.0
security:
authorization: enabled
And I'm starting it via systemctl which does this:
/usr/bin/mongod --quiet --auth --config /etc/mongod.conf
Created an admin user like so:
mongo
> use admin
> db.createUser({ user:"user001", pwd:"pwd001", roles:[{role:"root", db:"admin"}]})
I can access mongo on EC2 via:
mongo -u user001 -p pwd001 --authenticationDatabase admin
However, when I try to access it on my local via:
mongo -u user001 -p pwd001 --authenticationDatabase admin --host 58.17.53.6
I get this error:
MongoDB shell version: 3.0.4
connecting to: 58.17.53.6:27017/test
2017-10-30T19:42:33.302-0700 W NETWORK Failed to connect to 58.17.53.6:27017 after 5000 milliseconds, giving up.
2017-10-30T19:42:33.304-0700 E QUERY Error: couldn't connect to server 58.17.53.6:27017 (58.17.53.6), connection attempt failed
at connect (src/mongo/shell/mongo.js:181:14)
at (connect):1:6 at src/mongo/shell/mongo.js:181
exception: connect failed
Also, my security group for instance looks like this:
Any help would be appreciated!