ubuntu sudo service mongod status shows failed but mongo is working - mongodb

I started a replica set with three servers with default port and used a different data directory. But when i did sudo service mongod stop. it said failed. so i went into mongo shell and did a shutdown and mongo shell stopped working. now when i did sudo service mongod start it said failed but i was able to go to mongo shell and the reolica set was working. I checked sudo service mongod status it said failed.
sudo service mongod status
[FAIL] Checking status of database: mongod apparently not running failed!
i edited mongod.config to have a replica set name , commented out bind_ip, used keyfile for auth

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 in Linux Mint 19

I am trying to use mongoDB in Linux mint 19. But I am getting below error.
What is the solution ?
You're starting the mongo shell client, which by default tries to connect to a mongod server running on localhost and listening on port 27017. However, there is no server listening there so the mongo shell notes that and exits.
You'll need to investigate why there was no mongod server listening there:
The MongoDB Server package isn't installed
You're specifying a non-default port in e.g. /etc/mongod.conf
The mongod process/service is not running
...
First verify that the Server package is installed:
sudo dpkg -l | grep -i ".*mongodb.*server"
Then check the status of the mongod service and go from there. That will tell you if it's running, what port it's listening on, what config file is used, etc.
sudo systemctl status mongod
If it's not running then try to start it:
sudo systemctl start mongod
If it's still not running then look at the log messages:
sudo journalctl -u mongod.service

MongoDB Failing to Start - ***

I have configured mongodb with yu on linux.
enabled systemctl enable mongod.service as well, when ever exit do ctrl+c,
systemctl status mongod.service status is failed
mongod --port 27017 says connecting.. but status is still failed.
netstat show port 27017 is listening
any suggestions?
db version 3.2.4, in rc.d/init.d not able to find mondo script, for chkconfig mongod on

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

mongodb error. how can I solve the erro in mongoDB?

MongoDB shell version: 3.2.6
connecting to: test
2016-05-08T10:46:12.023+0530 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2016-05-08T10:46:12.023+0530 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:229:14
#(connect):1:6
exception: connect failed
https://docs.mongodb.com/v3.0/tutorial/install-mongodb-on-ubuntu/
Do you have the mongodb service running? Run sudo service mongod status and see what it returns. If it is stopped, run sudo service mongod start to start the mongodb and try connecting to it.
You can also, check whether the mongodb is listening on 27017 or not by running: sudo netstat -lnp | grep 27017.
If sudo service mongod start is giving a error, you may need to check the configuration. We can help you better if you can post the output of the above commands.
Update:
Create the file /etc/systemd/system/mongod.service with the following content:
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf
[Install]
WantedBy=multi-user.target
Just restart the service in terminal, verbose mode helps you to understand the background configuration
$brew services restart mongodb --verbose
and open another terminal (don't use same terminal) and type mongod, you should be able to see process running.
Excuse have the same problem . Just installed Ubuntu 16.04 LTS . The installation process , the same as in the official website of mongo . When I do:
sudo service mongod status; appear
● mongod.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
I guess the error will be in the configuration of "data directory" and the port, but not as configure it properly
Fork your mongodb process as a daemon so that it keeps running in background. E.g
./mongod --port 27017 --dbpath /home/db_directory --logpath /logs/mongod.log --fork