root@Wavynn-master:~# sudo service mongod start
root@Wavynn-master:~# mongo
MongoDB shell version v4.2.1
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
2019-11-04T18:18:00.829+0000 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:341:17
@(connect):2:6
2019-11-04T18:18:00.830+0000 F - [main] exception: connect failed
2019-11-04T18:18:00.830+0000 E - [main] exiting with code 1
Hello. I have been attempting to pair my mongoDB with compass, compass asked for a authentication database, in which I used a tutorial, where I created a db called admin, and an admin role having all permissions to all databases.
This can be seen here
use admin;
switched to db admin
> db.createUser({
... user: "admin",
... pwd: "*********",
... roles: [
... {role: "userAdminAnyDatabase", db: "admin" },
... {role: "readWriteAnyDatabase", db: "admin" },
... {role: "dbAdminAnyDatabase", db: "admin" }
... ]
... });
Successfully added user: {
"user" : "admin",
"roles" : [
{
"role" : "userAdminAnyDatabase",
"db" : "admin"
},
{
"role" : "readWriteAnyDatabase",
"db" : "admin"
},
{
"role" : "dbAdminAnyDatabase",
"db" : "admin"
}
]
}
Right after this issue started occuring.
Anyone have any suggestions as to how we fix this issue? Also a tip towards how we connect compass with mongoDB on ubuntu :)
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
I see this tutorial It has a line of code that says configure your firewall to listen to remote connection at port 27017 form specific id
sudo ufw allow from client_ip_address to any port 27017
but as I was don’t have a static IP for my remote client that needs to be connected to mongodb remotely, so I cannot anticipate what will be the IP of my client that’s why I added ANY instead of IP address like this
sudo ufw allow from any to any port 27017
which is of course expose your db to potential security risks but it worked for me.
I wont recommend it to anyone, One should add ip address of client instead of “any”
Thanks
hello i have the same problem i would like to know how are you fix it
I was facing the same issue in ArchLinux. I just restarted my mongodb service with sudo systemctl restart mongodb.service and worked for me.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.