Brew MongoDB autoload mongod on login - run mongo as a service - mongodb

I am confused.
brew services list is showing me that mongod is being loaded at login
mongodb started - /Users/myuser/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
but, when I do mongo I get Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
How do I make mongod to start as a service? The content of the .plist file can be viewed here: http://pastebin.com/itxUtZ8M
Any suggestions much appreciated. P.S. I am running on OS X Maverick (OS X 10.9.2)

Starting mongod manually with the command /usr/local/opt/mongodb/bin/mongod --config /usr/local/etc/mongod.conf showed that something was wrong with the log file:
FileNotOpen Failed to open "/usr/local/var/log/mongodb/mongo.log"
As it turned out, the owner of the file was wrong. Changing it to myuser solved the problem. See comments below the question for details.

Related

Mongo server error "No connection could be made because the target machine actively refused it."

MongoDB shell version v4.4.3
connecting to: mongodb://127.0.0.1:27017/admin?compressors=disabled&gssapiServiceName=mongodb
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:374:17
#(connect):2:6
exception: connect failed
exiting with code 1
I get this error when I try to run my mongo server, It has worked previously but not it doesn't. I have no idea what to do, please help.
This error can come up for a couple reasons. If I were to begin troubleshooting this connection, I would try restarting the MongoDB service on your local computer; as it looks like you are trying to connect to a local instance of mongodb.
The reason for this error is, you have stopped the mongodb server. Follow these steps to start mongodb server. First open task manager and go to the services tab. Then check the server status. If it is stopped, right click on it and start.
enter image description here
IF you are on window then go to your directory where server files is there.
under that check that mongod.lock file have some value.
Kindly delete the file
After that try to delete the service and then recreate the service
Delete service:
sc delete mongodb
ReCreate the Service:
sc.exe create arbiter binPath= "\"C:\Program Files\MongoDB\Server\4.4\bin\mongod.exe\" --service --config=\"C:\data\mongodb.cfg\"" DisplayName= "mongodb" start= "auto"
Now start the service with the command
net start mongodb
Please give the comment about your attempt. I will be happy to help if problem not solved.

MongoDB won't connect on Ubuntu 14.04

I am trying to install MongoDB on Ubuntu 14.04 LTS. I am following the article at the link below:
https://docs.mongodb.com/v3.0/tutorial/install-mongodb-on-ubuntu/
Everything is fine, and my log file shows the following line:
2016-12-18T20:47:19.476+0000 I NETWORK [thread1] waiting for connections on port 27017
I also get the following status when i run the following command:
bitnami#ip-172-31-58-13:service mongod status
bitnami#ip-172-31-58-13:mongod start/running, process 15587
however, as soon as i try to connect to mongo, I run into an error, which I simply cannot seem to resolve.
Command:
bitnami#ip-172-31-58-13:/var/log/mongodb$ mongo
Output:
MongoDB shell version: 3.0.7
connecting to: /opt/bitnami/mongodb/tmp/mongodb-27017.sock:27017/test
2016-12-19T00:08:48.809+0000 W NETWORK Failed to connect to /opt/bitnami/mongodb/tmp/mongodb-27017.sock:0, reason: errno:2 No such file or directory
2016-12-19T00:08:48.810+0000 E QUERY Error: couldn't connect to server /opt/bitnami/mongodb/tmp/mongodb-27017.sock:27017 (/opt/bitnami/mongodb/tmp/mongodb-27017.sock), 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
bitnami#ip-172-31-58-13:/var/log/mongodb$
I have tried everything on the internet (gone through about 50+ articles) but nothing seems to work - changing the .lock file, updating the permissions, even uninstalled and re-installed mongodb 2 times and so on.
I noticed that the mongodb-27017.sock is placed under /tmp rather than /opt/bitnami/mongodb/tmp/ but I am not sure if that is a problem?
Please help me in resolving this issue.
Thank you

error connecting to mongodb service on windows

I recently started the mongodb service on my windows machine, and it is running succesfully. Or at least I think it is, though I am not 100% sure and I don't know what port it is running on because all attempts to check the status have failed. When I try to run mongo.exe, I get the following error:
paul#PAUL_LAPTOP /c/program files/mongodb 2.6 standard/bin
$ mongo
MongoDB shell version: 2.6.3
connecting to: test
2014-08-11T03:36:15.802-0400 warning: Failed to connect to 127.0.0.1:27017, reas
on: errno:10061 No connection could be made because the target machine actively
refused it.
2014-08-11T03:36:15.808-0400 Error: couldn't connect to server 127.0.0.1:27017 (
127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed
Any ideas how I could check why this is happeing? One good first step would be checking the status of my mongo service, which I am not sure how to do.
Any help is greatly appreciated.
Thanks,
Paul
Have you gonbe through all the steps here: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/?
You need to run the mongod command to start mongodb, and you also have to define the path where mongodb shall store your database:
C:\mongodb\bin\mongod.exe --dbpath d:\test\mongodb\data
When you typed in the mongod command, did you also give it a path? This is the step beforehand and this is usually the issue.
mongod --dbpath="put your path to where you want it to save the working area for your database here!! without these silly quotations marks I may also add!"
example: mongod --dbpath=C:/Users/Kyle-3/Desktop/DEV/dangerzonearea/test/mongodb
That is my path and don't forget if on windows to flip the slashes forward if you copied it or it won't work!

Amazon Linux AMI with MongoDB installed - service FAILED to start

I have mongodb installed on a new Amazon Linux AMI after implementing the guide here. When running "service mongod start" though, I just get a Starting mongod FAILED message. Nothing else. Blank log file also.
service mongod stop yields a FAILED also.
service mongod status yields "mongod is stopped"
Any thoughts or next steps?
I faced the same problem with my master mongodb instance. I have a replica set of 3 instances on EC2 and I had the same problem after one reboot that we needed for it, mongod simply failed to start.
First thing I did, was changed the ownership of the log file that is set up in the mongod.conf:
sudo chown mongod:mongod <LOG FILE>
After this I tried only sudo mongod and this will log the problem why the service won't start in the log file.
Mine appeared to be some ownership issues with the WiredTiger conf files in the dbPath directory (were set to root ownership instead to mongod user)
What I do in that case is use
sudo killall mongod
and after that it starts ok. My suspicion is that there is a running instance and that's why it fails to start.

mongodb not starting after reboot for my rails3 app

Due to power outage my computer crahsed while working on rails3 app. My mongodb is not restarting ever since.
MongoDB shell version: 2.4.10
connecting to: test
Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145
exception: connect failed
Noticed after reboot /data/db is missing. Went ahead and created it, but for some reason it is still not starting. Appreciate inputs here
I think the issue is due to mongodb lock.
Try this:
sudo rm -rf /var/lib/mongodb/mongod.lock
and restart your service.