Windows could not start mongodb service on local computer. For more info., review the System Event Log - mongodb

I am using Windows 32-bit machine and tried to start MongoDB service from Windows > services as shown below.
However, I am unable to start the MongoDB service from it and throws the following error.
When I try using cmd prompt, I am getting the following error:
Network Failed to connect to 127.0.0.1:27017, reason: errno:10061 No
connection could be made because the target machine actively refused
it.
Error: Couldn't connect to server 127.0.0.1:27017 <127.0.0.1>,
connection attempt failed.

I had same an issue.
Try to remove mongod.lock file from your Mongo data directory.
For example mine is "C:\Program Files\MongoDB\Data\mongod.lock" and after deleting file start the MongoDB service and it's work like charm.

In case someone else is running into this problem, just read your Log files and you will be able to find the problem, for me after trying to install it inside wamp directory when I run the MongoDB service it gave me the same error message, I went to the logs and find out that I was missing a directory inside my data directory which is called db, once I have created this directory the service run perfectly.

MongoDB uses a default folder to store its files. On Windows, the default location is C:\data\db.
Maybe that folder doesn´t exist. In that case just creat it or change the default location of Mongo service using the --dbpath command-line flag.

So I just had the same problem, running on Windows 10. The reason why MongoDB didn't start was because the path to the data and logs was not correctly set. This has already been pointed out, but my solution is different. Look in C:\Program Files\MongoDB\Server\4.0\bin (or wherever your mongoDB is installed). There is a config file called mongod.cfg. Check that
storage:
dbPath:
and
systemLog:
path:
Is set to what you want. In my case, it was using environment variables %MONGODBPATH% or similar that was not set by Windows. By default, the log and data should point to C:\Program Files\MongoDB\Server\4.0\data and C:\Program Files\MongoDB\Server\4.0\log\mongod.log respectively.

There was a npm: in last line of mongodb configuration file which is located in the installation folder in the bin\mongod.cfg
I commented out that line and started the service and it is working like charm.
I concluded this by running the mongodb service command from windows command line(cmd) and I got an error.
I ran this to spot the error:
C:\Program Files\MongoDB\Server\4.2\bin\mongod.exe --config "C:\Program Files\MongoDB\Server\4.2\bin\mongod.cfg" --service

mongod.lock deletion did not helped me, repair did not help either. In my case it was due to one of database happened to be corrupted, I moved all dbs to another directory and then copied them back one by one and re-starting mongodb service to figure out what db file is corrupted. It's definitely MongoDb bug

I had the same error message. Try to locate the mongodb log files and look at the last entries. My issue was clearly stated there, a missing directory :
2019-01-29T16:59:44.424+0100 I STORAGE [initandlisten] exception in
initAndListen: NonExistentPath: Data directory
C:\wamp64\bin\mongodb\mongodb-win32-x86_64-2008plus-ssl-3.6.10\data\db
not found., terminating

The advice of checking the log was what helped me. In this case:
The MongoDB service could not be started. A service specific error occurred: 100
turns out I had a problem with some databases created with WiredTiger while the mongod.cfg specified engine was: mmapv1
So I basically removed the content of the folder c:/data/db/ and then used the command net start MondoBD --repair and worked. Uffff it´s been 2 days.

I'm here a bit late, very late actually. But may it works something out for the ones facing this issue now. Mongodb configuration file in Windows OS is under 'C:\Program Files\MongoDB\Server\%YOUR MONGO VERSION%'.
I had changed this file and manipulated the bindip field, so I was getting the same error. It should be 127.0.0.1 or your machine's IP address which you can find it by 'ipconfig/all' command in cmd. So I fixed bindip and the service starts with no problems.

stuck on the same issue, but got the solution by hit and trial, just create a new folder for path "C:\data\db" then go to your command prompt and type 'mongod', your database server will start.

For me it was a port problem :
just search and kill the process using the port 27017
for linux : https://bobcares.com/blog/mongodb-error-code-48/
for windows : How do I kill the process currently using a port on localhost in Windows?

I have found out that Visual C++ Redistributable was missing in my Windows 7 Machine. After installing it worked.

For Windows 10 users
specify database location, if don't know create the below-mentioned directory and always use this
open cmd
mkdir C:\users\{username}\data
cd C:\users\{username}\data
mongod --dbpath .
start mongodb server
open cmd
mongod --dbpath C:\users\{username}\data
stop mongodb
open cmd
mongo
if server is running, run:
use admin
db.shutdownServer()
quit()

In my case, this happened because I did not stop MongoDB from docker. after I stopped the process the error was gone.

In my case, it was the docker with MongoDB running on the same port. So after I stopped the container, the service is then successfully starting.

Related

Mongo is unable to start

I'm trying to start mongo uin windows10 by type: mongo in cmd.
I am getting this error:
C:\Users\Itzik>mongo
MongoDB shell version v3.4.1
connecting to: mongodb://127.0.0.1:27017
2016-12-26T19:00:16.604+0200 W NETWORK [main] Failed to connect to 127.0.0.1:27017 after 5000ms milliseconds, giving up.
2016-12-26T19:00:16.605+0200 E QUERY [main] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:234:13
#(connect):1:6
exception: connect failed
C:\Users\Itzik>
I have opened port 27017 in the firewall,
and restart mongo's services
and it still dont work.
what could it be?
Have you started the server? Mongodb follows a server-client architecture. mongo is the client, but before it is started you need to start mongod, which is the server.
If you haven't, start the server in advance in a different console:
mongod --dbpath "c:\data"
replacing c:\data by any folder where you want to store your data (you need to create the folder in advance).
If mongod is not in the path look in the installation path, it should be something like C:\mongodb\bin\mongod.exe.
When the server says something like 'waiting for connections', then you can go to another console and type mongo to start the client.
In C:\Program Files\MongoDB\ you might not have permission to create file/folder for your user. And mongo installer cannot create it because of lack of Administrative permission for your user.
So in C:\Program Files\MongoDB:
Create a folder named data
Create a folder named db inside the folder data
Now right click on the data folder and choose properties
Click security tab and select your user there
Click the Full control select box
Click ok, ok, ok ...
important! if you don't have the path "C:\Program Files\MongoDB\Server\3.4\bin" set in environment variable, please set it.
Now go to shell and type : mongod --dbpath "C:\Program Files\MongoDB\data\db"
That's it :)
First start the server.
Goto your installation path. Mine was in "Program Files/Mongodb/server/bin"
You will find a "mongod.exe" application.
However, the server will look for "C:/data" folder for all the databases.
So create the "C:/data" folder.
Now start the mongod.exe using command prompt.
>>mongod
After this you may start the client
>>mongo
This worked out for me.
Open the terminal as Administrator.
(You can simply do this by searching cmd in start and then right click and select "Run as administrator")
Go to bin directory of your MongoDB folder.
cd C:\Program Files\MongoDB\Server\3.4\bin
Type following command to start mongodb server :
mongod --dbpath "C:\Program Files\MongoDB\Server\3.4\bin\Data"
now, server will be waiting for connections.
Open a new command prompt(again as Administrator)
Go to bin directory.
cd C:\Program Files\MongoDB\Server\3.4\bin
Type following command:
mongo
This will show you a prompt of mongodb :
>
Thanks.
if u install by brew (on osx)
first run sudo mkdir /data/db
start mondoDB Daemon by typing mongod (leave it open) and then
run mongo by typing mongo in new terminal tab
I also have faced the same problem.
First i have typed mongodb in my command prompt ,It displays "waiting for connection on 27017" that means it is working.
Then i type mongo in another Command prompt Window then above error occurred.
I was having both .dll files in my xampp\php\ext folder.
(php_mongo.dll and php_mongodb.dll)
I deleted Php_mongodb.dll and also it's extension from php.ini file.
Again restart command prompt,Type mongod and then mongo
Now working correctly.
First set the path in Enviroment Variables, C:\Program Files\MongoDB\Server\3.6\bin
after that use bellow command
C:\>mkdir data
C:\>cd data
C:\data>mkdir db
C:\data\db>
Then go to bin directory and select mongod.exe or use mongod. Without closing previous cmd
open a new cmd and start the client using mongo
Now it will work.
This issue is resolved by creating a data directory
Then move to the bin folder of mongodb or setting path information in environment variables
Then you can enter the following command,
mongod --dbpath 'path of the data folder including data directory name'
Eg: mongod --dbpath c:\users\codemaker\data

MongoDB : A Service Specific error occurred :100

I have just installed "mongodb" on Windows, while starting it, the following error appears
A Service Specific error occurred :100
Any Suggestions?
The reason for this error message is that you have another process already established.
In my case it was the mongod.exe file I had opened in CMD, when I closed it and restarted the net start MongoDB command, it connected successfully.
BTW i am using Windows 10 current build as of July 2017 with MongoDB 3.4
Please try running the below commands as Administrator in the comment prompt.
mongod --repair
mongod --remove
then like #Yahya did, specify the log path,
mongod --install --logpath C:\data\db\log\mongo.log
net start mongodb
Hope it helps.
For me, somehow directories I have specified for db and log config file were not auto created.
dbpath=\data\db
logpath=\data\log\mongo.log
so I created them manually then ran the command again and service started.
I am using v3.4.9 om Windows 10
Check your Mongo log in your /data/log folder (which you should have created during install), there might be a solution in there.
I had this issue, I checked the System Event Log which gave me the following:
The MongoDB service terminated with the following service-specific error: Cannot create another system semaphore.
When I checked the log I found this:
Unable to create/open lock file: c:\data\db\mongod.lock The process cannot access the file because it is being used by another process.. Is a mongod instance already running?
Turns out I'd started the process manually in another command window so it couldn't start it again. You may have a different issue but the log should tell you what is going on!
execute the command
"C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe"
and check which error is displayed
Running mongod.exe through a service does not display the error messages. In my case, i didnt created the directory /data/db, which i specified in my configuration file. My Configuration file is based on the docs create-a-configuration-file
The error was only displayed after executing the command directly
For example mongoDB version 3.6 is installed, and the installing path of MongoDB is "D:\Program Files\MongoDB".
Create folder D:\mongodb\logs, then create file mongodb.log inside this folder.
Run cmd.exe as administrator,
D:\Program Files\MongoDB\Server\3.6\bin>taskkill /F /IM mongod.exe
D:\Program Files\MongoDB\Server\3.6\bin>mongod.exe --logpath D:\mongodb\logs\mongodb.log --logappend --dbpath D:\mongodb\data --directoryperdb --serviceName MongoDB --remove
D:\Program Files\MongoDB\Server\3.6\bin>mongod --logpath "D:\mongodb\logs\mongodb.log" --logappend --dbpath "D:\mongodb\data" --directoryperdb --serviceName "MongoDB" --serviceDisplayName "MongoDB" --install
Remove these two files mongod.lock and storage.bson under the folder "D:\mongodb\data".
Then type net start MongoDB in the cmd using administrator, the issue will be gone.
This error occurs due to that service is already started. If you are not done it, then please check your database path and log path in the mongodb.cfg (The file which stores mongodb configuration) file.
Eg:
systemLog:
destination: file
path: H:\data\log\mongod.log
storage:
dbPath: H:\data\db
processManagement:
windowsService:
serviceName: "MongoDB"
displayName: "Mongo DB"
description: "mongod service"
If you doesn't have it then please create one.
Also you can use the following step to fix this issue,
please run the follow as administrator.
sc.exe qc MongoDB
If there are no logs, then MongoDB likely cannot open the log file due to a permission issue.
Also, try installing the service as
D:\servers\db\mongodb\bin\mongod.exe --dbpath=D:\servers\db\mongodb\data --logpath=D:\servers\db\mongodb\log\mongo.log --logappend --install
I fixed my issue
In the config one of the path was
C:\MongoDB\data\db
But nor the data or db folder existed
I expected them to be generated automatically.

MongoDB on a Windows 7 machine: No connection could be made

After I have started Mongo using mongod.exe on a Windows 7 machine, I tried to start the mongo shell that failed with the error:
Failed to connect to 127.0.0.1:27017, reason: errno:10061 No
connection could be made because the target machine actively refused
it.
...
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
In the CMD where I running the mongod the output is:
C:\Users\Vera>mongod --dbpath c:\mongodb\mongodata
2014-05-18T17:10:10.135-0300 [initandlisten] MongoDB starting :
pid=3296 port=27017 dbpath=c:\mongodb\mongodata 64-bit host=Vera-PC
2014-05-18T17:10:10.136-0300 [initandlisten] targetMinOS: Windows
7/Windows Server 2008 R2
2014-05-18T17:10:10.136-0300 [initandlisten] db version v2.6.1
2014-05-18T17:10:10.136-0300 [initandlisten] git version:
4b95b086d2374bdcfcdf2249272fb552c9c726e8
2014-05-18T17:10:10.136-0300 [initandlisten] build info: windows
sys.getwindowsversion(major=6, minor=1, build=7601, platform=2,
service_pack='Service Pack 1')
BOOST_LIB_VERSION=1_49
2014-05-18T17:10:10.136-0300 [initandlisten] allocator: system
2014-05-18T17:10:10.136-0300 [initandlisten] options: { storage: {
dbPath: "c:\mongodb\mongodata" } }
2014-05-18T17:10:10.242-0300 [initandlisten] journal
dir=c:\mongodb\mongodata\journal
2014-05-18T17:10:10.243-0300 [initandlisten] recover : no journal
files present, no recovery needed
2014-05-18T17:10:11.077-0300 [initandlisten] waiting for connections
on port 27017
Any suggestion how to fix this issue?
I got the same error and fixed it with:
1) mkdir c:\data
2) cd data
3) mongod -dbpath .
4) Now in another command window I was able to connect from my client using the mongo command.
I got this problem. What fixed mine is:
Suppose you have a dir: "C:\mongo_databse"
Open Command Prompt and type (suppose you haved added the Mongo bin directory to PATH): mongod --dbpath=C:/mongo_database.
There will be some log to the command prompt.
Now open ANOTHER command prompt then type in mongo then it works.
What solved my issue was creating a file startmongo.conf that sets the bind_ip to 127.0.0.1 . After that, I just created a *.bat to start the mongo using something like:
mongod --config c:\mongodb\bin\startmongo.conf
More details could be seem at this post .
I assume your mongo.config file to be located inside the mongodb folder in the same level to the bin directory.The contents of the mongo.config file are:
dbpath=C:\mongodb\data
logpath=C:\mongodb\log\mongo.log
diaglog=3
don't forget to create the data folder and log folder in the same level of bin directory inside log folder create the mongo.log empty file.
Point your command prompt to C:\mongodb\bin wherever your mongo db bin folder is located.
create the mongo db service in windows typing
mongod.exe --storageEngine=mmapv1 --config=../mongo.config
from now unwards you can start the mongo db service as
net start mongodb
finally you can connect to the mongo db server from the mongo db client typing
mongo.exe
once you have gone successfully from step 1 to step 3 from the next time on wards you only need the step 4 and 5.to start the service and to connect.
it prompted me like this
1)So, i created a path
C:\data\db
2)Now run
mongod in your terminal
it solved me issue!
I got this error beacuse of not sufficient space in the disk.
Check your mongo log.
I was getting a similar error when I was trying to start my mongo db via cmd. However the difference was I had a config file which has the path to the db and log folders and wanted to use the same. I was using mongo few days back and it was running fine but when I started using it again today it was giving me the error :
2015-05-27T10:33:22.820-0400 I CONTROL Hotfix KB2731284 or later update is installed, no need to zero-out data files
MongoDB shell version: 3.0.2
connecting to: test
2015-05-27T10:33:23.854-0400 W NETWORK Failed to connect to 27.0.0.1:27017, reason: errno:10061 No connection could be made because the target machine actively refused it.
2015-05-27T10:33:23.857-0400 E QUERY Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at connect src/mongo/shell/mongo.js:179:14) at (connect):1:6 at src/mongo/shell/mongo.js:179 exception: connect failed
Here's how I fixed it :
Open cmd as admin and navigate to the bin folder of your MongoDB and type : mongod --config <path to your config file> --install
Now start your mongo db service : net start mongodb
you should get a message which says : The MongoDB service was started successfully.
close this command prompt and open another one as admin, navigate to the bin folder once again and type mongo
This will connect you to the mongodb test.
Press ctrl+c anytime to exit.
Hope this helps.
In Windows 10:
Executing below command restarts mongodb service (as administrator), required if there is a system restart after mongodb installation.
net start mongodb
Also make sure to check, if there is a MongoDBInstallation folder/data and /data/db folder created, same can be obtained at MongoDBInstallation\bin\mongod.cfg
mongod --dbpath=c:\MongoDBInstallation\data\db
Open task manager, click on the services tabs on the top. From the list right click on mongoDB then click start.
I had a very similar experience to #user1501382, but tweaked everything slightly in accordance with the documentation
1) cd c: //changes to C drive
2) mkdir data //creates directory data
3) cd data
4) mkdir db //creates directory db
5) cd db //changes directory so that you are in c:/data/db
6) run mongod -dbpath
7) close this terminal, open a new one and run mongod
for mongodb 3.0 versions use "--smallfiles".
e.g:-
mongod --dbpath="C:\Program Files\MongoDB\Server\3.0" --logpath="C:\Program Files\MongoDB\Server\3.0\data\log.txt" --smallfiles --install
I am not sure if there is a better way to run it.
For me, I use these settings to create a directory and to a determinate new path for the MongoDB.
The important thing for me is that I miss to run it as a server (mongod) and after that into another terminal I type mongo which provide me an option to use the database.
I hope this could help someone.
I found my answer on this page. https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mongo-app?view=aspnetcore-3.1&tabs=visual-studio
So, first, make a folder for your data; then, open one command shell
mongod --dbpath <data_directory_path>
then, open another shell, do whatever you want to do. You can see in MongoDB Compass, there are collections if you had one before.
I tried the above answer
, and it worked, but had a very important problem: My previous collections were lost in another mongoDB data folder which I didn't know where they are and how to get them back.
Before I run in to this mongo error, I was running mongo with no problem. When my windows10 boot files got corrupted and My computer went into blue screen, mongo ran into this error. So I just tried to retrieve the previous condition which I just was running mongo in one terminal and not mongod in another, so
I repaired mongoDB with it's installation exe file, and now everything is ok.
This is my mongoDB specs: mongodb-win32-x86_64-2012plus-4.2.1
Hope this help you too.
Just type mongod in one command prompt and then run mongo in another.
Simply follow the following steps mostly your problem will be solved(Windows 10)
services->mongodb->change auto to run
you can go to services>>Mongo DB server .. right click and press start . This worked for me
By simple step ,I was resolve this problem
first step - make a New folder in C-drive in PC with name - "data"
second step- now open this "data" folder
Third step - Inside the "data" folder, again make a new "db" folder
Note - Just leave it this both folder empty, no need to add any content inside this,
and run "mongo" and "mongod" in PowerShell of your PC.
I got the same error, and this is how I resolved it,
follow the below steps:-
Open mongod.cfg file
Add the bindIpAll: true tag in the
net (Network Interfaces) section
restart the mongoDB services.
# network interfaces
net:
port: 27017
bindIpAll: true
#bindIp: 127.0.0.1

connecting to test mongoDB is failed

I am new in mongoDB
I have tried to install mongoDB on win 8 - 32 bit
I followed "The Definitive Guide To MongoDB 2010" by Apress.
I pasted the file in C drive root "mongodb-win32-i386-2.4.6"
Then I created nested folder in C
data/db ,
As the book was mentioned.
After that I opened cmd :
cd C:\ mongodb-win32-i386-2.4.6
cd bin\
up to here everything went well
then I tried to connect to mongo
but :
mongo
couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145
exception: connect failed
occured.
Where is problem?
Thanks in advance
First Thing is
MongoDB is almost always run as a network server that clients can connect to and
perform operations on so
create a folder data and in that db folder i.e., c:\data\db
First we need to start the server with the command mongod.exe avial in your bin folder
like C:\mongodb-win32-i386-2.4.6\bin\mongod.exe
Run the mongo.exe avail in the bin folder like C:\mongodb-win32-i386-2.4.6\bin\mongo.exe
Know How to stop the mongod.exe
from the client we need to issue these commands
use admin
db.shutdownServer()
then automatically mongod will shut and you need to quit from client with exit command
HAVE A NICE DAY WITH MONGO
The database itself is an executable called mongod.exe (mongoDB daemon). First you need to start this one. When it is running, you can use mongo.exe (mongoDB shell) to connect to it and issue commands.
For more information, read the article "Install MongoDB on Windows" from the official manual.
i have tried the binary files from https://www.mongodb.org/dl/win32/i386
After installing above binary file please go to bin directory (C:\Program Files\MongoDB\Server\3.2\bin -> default installation directory) and run following command
mongod.exe --journal --storageEngine=mmapv1 --dbpath c:\data\db
Note:make sure that you have already created the c:\data\db directory
Also if you need a GUI interface for mongodb, you can use Mongobooster

Moved Mongo Database to Different Drive: Unable to acquire lock for lockfilepath

I am in the process of moving my mongo data to a different drive. All of the data I want to move is stored in /data/db and I am moving it to a NAS (Network attached storage).
First step:
mongodump -d mydb -c mycollection -o nas/mongo-temp
This created a file tree in mongo-temp/ like so:
dump
`-- mydb
`-- mycollection.bson
1 directory, 1 file
I then stopped the mongod service and created a new /data/db directory:
/etc/init.d/mongod stop
mkdir mongo-temp/data/db
...and changed the dbpath line in /etc/mongodb.conf
dbpath=.../mongo-temp/data/db
I successfully restarted the mongo server using /etc/init.d/mongod start.
When I try to connect:
mongo
MongoDB shell version: 1.6.4
Thu May 3 09:53:23 *** warning: spider monkey build without utf8 support. consider rebuilding with utf8 support
connecting to: test
Thu May 3 09:53:24 Error: couldn't connect to server 127.0.0.1 (anon):1154
exception: connect failed
I've tried to start mongod with the command mongod --dbpath .../mongo-temp/data/db but I get an error that says:
Thu May 3 09:57:26 exception in initAndListen std::exception: Unable to acquire lock for lockfilepath: /home/dlpstats/nas-mnt/mongo-temp/data/db/mongod.lock
Removing the lockfile doesn't help. If I run the mongod command without --dbpath, the server starts fine and I am able to make queries on my old database.
First, you mentioned that you used mongodump to populate the new drive - was this just a method of backing things up or did you intend that to be the new database files? That is not how it works - mongodump output is not the same as a database file - it needs to be re-imported with mongoresore in fact. If you do a straight data file copy then the transfer will be seamless.
Then, as well as the permissions suggested by Wes in his answer, a few more things to check:
That you have shut down the old server successfully and completely - it's possible it's mis-reported error and you are getting it because it is trying to grab a port that is already open
You are using version 1.6.4 according to the mongo shell output, my guess is that you installed from the Ubuntu repo for 11.04 or similar, that is not a good option - 1.6 is very old at this point. Use the 10gen repos (http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages) or download the binaries and get a more recent version
Last but not least, when you start the mongod manually, make sure all the arguments are the same, like the port. When you connect via the mongo shell, specify the port you started the mongod on - don't rely on defaults when running into issues like this, be explicit.
I faced this problem and issuing following command solved my problem:
rm /var/lib/mongodb/mongod.lock
And then restart the mongod.
But I'm not sure is it a good solution or not.
Check the permissions for the directory and parent directories of mongo-temp. Presumably it's running as the mongodb user?
You need execute permissions on the directory (and parent directories) in order to create files there. Execute permissions on a directory allow you to list the files there, which is needed to be able to open the file for writing.