Cannot access to my datsbase when running the server as a service - mongodb

I have recently installed Mongodb on my ubuntu machine according to the linux manual in mongodb website. everything looks ok when i run the command "mongod" to start a mongodb server.when I try to run
sudo service mongod start
it says that mongod start/running, proccess 3369
but when I try to access the database from the Mongodb GUI it cannot acces it. nor from the chrome itself using the port 27017.
how can i fix this?

Related

MongoDB, NodeJs. No connection could be made because the target machine actively refused it. :

I am trying to connect to my MongoDB database in localhost. While I type mongo in command shell I am getting an error in the command shell:
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 :: No connection could be made because the target machine actively refused it. :
connect#src/mongo/shell/mongo.js:341:17
This will start the mongo server as a service:
brew services start mongodb-community
command mongod will run the MongoDB server using the default configuration. You can change these configurations by locating the default path of the configuration files.
The primary daemon process for the MongoDB database system is called mongod. You need to start this service before making connection attempts.
You can do this in Ubuntu by:
sudo service mongod start
or,
sudo systemctl start mongod
Start mongod on system boot by:
systemctl enable mongodb.service
I had the same issue.
When running mongod command, it mentioned the C:/data/db as E:/data/db path.
After I created the folder in mentioned E:/data/db path it works!
For windows user
1. Type ctrl + r
2. Scroll to mongodb server
3. start the server
do you have a linux distro? If you do, the solution is a bit annoying as you have to do it everytime you start your pc. The solution is:
Type "mongo" and "mongod" once in the terminal. It will show an error, don't worry, that's the whole point
type this:
chown -R mongodb:mongodb /var/lib/mongodb
chown mongodb:mongodb /tmp/mongodb-27017.sock
sudo service mongod restart
tip: copy the whole thing and paste on the terminal using ctrl+shift+v. You're welcome :-)

MongoDB Server Ubuntu 16.04

I've installed MongoDB on my Ubuntu 16.04 VPS and allowed connections through the firewall. When I run the server using the command (mongod), it starts without a problem and I can then connect to it (using RoboMongo as test application).
However, when I run the service automatically on startup (using systemctl), I cannot connect to it. I verified it was running, and could not run it myself as the address was already in use.
Does anyone have any experience with this, or any tips on how to solve the problem? The server will be running localhost only and I'm going to be using an SSH tunnel for testing purposes, so no authentication is necessary.
Anyone?
When you started mongod did you then provide a configuration file (using the --config or -f parameter)? If not then it defaults to listening on all interfaces.
The default configuration file which is used when starting the daemon with systemctl defaults to only listen on localhost preventing it from being available on the network. This is fine if you intend to connect to the server using a tunnel.

Laravel 5 and MongoDB connection

No suitable servers found (serverselectiontryonce set): [Failed connecting to '127.0.0.1:27107': Connection refused]
I install "jenssegers/mongodb": "^3.0" using composer, but am getting error, i can't connect mongodb.
I got this error when I had mistaken the IP of my machine. I was in VM and used 127.0.0.1, when I needed to use 10.0.2.2, IP of my host machine. Wasted an hour for this. Maybe it saves someone's time...
According to MongoDB documentation
mongod is the primary daemon process for the MongoDB system
According to above mentioned description ,it seems that mongod process is not running on your server and 27017 is default port for mongod instance
Please try executing following command to verify if mongod process is running on server
pgrep mongod
It will return process ID if mongod process is running on server otherwise nothing.
Issue following command in shell to start mongod process
mongod --noauth --dbpath /var/lib/mongodb
I had this error.
I had to restart mongodb to make this work.
I used the command below
sudo service mongod restart

How to start mongodb with new dbPath in a mongo session?

I have installed mongo on my server with sudo yum install mongo, i am using mongo to connect to my remote servers that actually have MongoDB installed on them (amazon servers).
At some point (during the backup restore) i need to issue a command like mongod --dbpath /$dbPath --replSet $replicaSetName on my MongoDb server, how can i do this from a mongo session? or if it is not possible, then how can i get the installation path to mongod?
Another thing is, i also have an mms account, is it possible to use their installed agent (on mongodb server) todo that?
thank you

Cannot connect to mongod running in Ubuntu machine

I would like to connect with mongo from a cmd shell in windows to a mongod database running in a Ubuntu virtual machine.
mongo is running fine in the Ubuntu terminal and from a putty shell
When I use mongo from a windows cmd shell, I got this error:
mongo.exe --host 192.168.1.6 --port 27017
MongoDB shell version: 2.4.6
connecting to: 192.168.1.6:27017/test
Sat Feb 01 14:45:32.181 Error: couldn't connect to server 192.168.1.6:27017 at src/mongo/shell/mongo.js:147
exception: connect failed
What should I do to be able to connect?
My goal is to use MongoVue to connect to the mongod database in the Ubuntu machine (by the way, MongoVue is not connecting even using its SSH options).
I am trying to connect to the mongod instance of a meteorjs application.
The meteor application is up and running and I can connect to the mongod instance running on the Ubuntu machine at port 3002, both in the Ubuntu terminal and with a putty shell.
stefano#MeteorDeploy:~$ mongo --port 3002
MongoDB shell version: 2.0.4
connecting to: 127.0.0.1:3002/test
PRIMARY> show dbs
local 0.0625GB
meteor 0.0625GB
I would like to connect to the mongod instance using MongoVue as alternative of the putty shell.
I did as in the docs.mongodb.org/manual/tutorial/configure-linux-iptables-firewall/ but without success.
Meteor runs it's own instance of mongo per app. As you note since your edit, when you ssh into your VM you use --port 3002 to connect.
Now you could add that port to your mongo shell launch except for one problem
ps -ef | grep mongo
on your VM will show you the running instance of mongo along with it's startup options. By default this will be bound to 127.0.0.1 which is the loopback adaptor and not accessible outside of the VM.
So what you need to do is either change the startup options in your project, or use another instance on mongo installed on the local machine.
export MONGO_URL=mongodb://localhost:27017/your_db
By default mongod insllation on Ubuntu only listen to localhost, so you can't connect from Windows.
Edit /etc/mongodb.conf and change the bind_ip line (add your windows IP adress on the local network) so it will accept connection.
Be aware that by default mongod does not require authentification so you would maybe want to settup one.
Doc is here :
http://docs.mongodb.org/manual/reference/configuration-options/#bind_ip
For quick and dirty solution (not for Production):
Edit /etc/mongodb.conf and change the bind_ip to 0.0.0.0