error connecting to mongodb service on windows - mongodb

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!

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

Mongo: network error while attempting to run command 'whatsmyuri' on host

I have been trying to access my mongo instance from another machine, but I get this error. I could not find many references to this whatsmyuri error. This is what I get from the external machine:
$ mongo <IP_ADDRESS>:27017/youtube_advertising -u user -p password
MongoDB shell version: 3.2.0
connecting to: <IP_ADDRESS>:27017/youtube_advertising
2016-02-19T17:10:02.923+0100 E QUERY [thread1] Error: network error while attempting to run command 'whatsmyuri' on host '<IP_ADDRESS>:27017' :
connect#src/mongo/shell/mongo.js:226:14
#(connect):1:6
exception: connect failed
I have already changed the /etc/mongod.conf file, opened connections through port 27017 (with iptables) and restarted mongo. I am able to connect via ssh to that machine.
Searching about this whatsmyuri, I ran this command on mongo:
> db.runCommand( { whatsmyuri: 1 } )
{ "you" : "127.0.0.1:36990", "ok" : 1 }
I do not know if that 36990 port is right or wrong. Just in case I opened connections from there too, but still nothing.
Any ideas?
UPDATE
Checking the /var/log/mongodb/mongod.log, this is what I get when I try to connect from remote:
2016-02-19T10:41:07.292-0600 I NETWORK [initandlisten] connection accepted from <EXT_IP_ADDRESS>:51800 #2 (1 connection now open)
2016-02-19T10:41:07.310-0600 I QUERY [conn2] operation isn't supported: 2010
2016-02-19T10:41:07.310-0600 I - [conn2] Assertion: 16141:cannot translate opcode 2010
Check your versions. That may help.
I was having the same problem. In my case, the server was version 3.2.0-rc2, while mongo shell version was 3.2.1.
Upgrading the server to 3.2.1 fixed the problem.
This issue bit me when I was running two versions (3.4 and 4.2) of MongoDB on the same Windows 10 machine. I ran v3.4 mongod with no problems mentioned in the console output, but then running the v3.4 mongo shell produced the above error. Checking the Task Manager, it turned out there was a MongoDB process (I'm not sure, but I think it was for v4.2) running. After ending that process through the Task Manager, the v3.4 mongo shell ran fine with no error.
Using mongodb-community-shell
In MacOs brew install mongodb/brew/mongodb-community-shell
It will ask you to overwrite link with mongo command.
brew link --overwrite mongodb-community-shell
The issue arises when the mongo client's and server's version mismatch.
Uninstall MongoDB from the client and for installation follow the detailed instruction provided over here.
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
The key step which needs to be done with the attention is
sudo apt-get install -y mongodb-org=4.2.7 mongodb-org-server=4.2.7 mongodb-org-shell=4.2.7 mongodb-org-mongos=4.2.7
mongodb-org-tools=4.2.7
Note: In my case, the mongo version of server was 4.2.7
Another thing that one can do is uninstall MongoDB from both the systems taking necessary backups and install it again.

MongoDB: Not working in windows

MongoDB is not connecting to the data bases. I added the path.
Whenever I run mongo it attempts to connect to test byt fails.
Error:
No connection could be made because the target machine actively refused it
Couldn't connect to the server 127.0.0.1:27017
Someone please help me!
Ensure Following:
Step1: Set path in Environment Variable.
\Program Files\MongoDB 2.6 Standard\bin;
Step 2: Create data directory
md \data
md \data\d
Step 3: Start mongo Shell
mongod
Step 4: Start Mongo
mongo
This Video from mongo university will help understand more easily.

Mongo: lost connection & collections

I was running a Rails rake task overnight on my local machine in order to seed my Mongo collection. It had probably generated about 45,000 records before I received the following exception:
Operation failed with the following exception: connection closed
Failed to connect to a master node at localhost:27017
I am on a Mac OS X, so I attempted mongo and received the following:
Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed
So I ran mongod thinking that this would simply start up the process. It now appears to have indexed new collections, because all of them are empty. Did I overwrite them, or might they still exist somewhere?
I ran ls /data/db and I see myapp_development.0 and myapp_development.ns. Does that tell me anything?
Sounds like your MongoDB data directory was set to somewhere other than the default (/data/db). Restarting would likely have started mongod with the correct --dbpath.
For example, if you followed a MAMP install guide the suggestion may have been to put the data directory inside /Applications/MAMP/db/mongo.
You should be able to find the dbpath used by running the following command in the mongo JS shell:
db.adminCommand('getCmdLineOpts')
Look for a parsed setting for "dbpath".