How To Connect To Mongodb Server In Windows
I'thou trying to run Mongo from the Command-Line: What'south incorrect? (I've IIS on localhost:80). And Apache on port 8080. Are there any issues with this?
C:\MONGO\Project1\mongo\bin>mongo --port 27017 MongoDB shell version: 2.0.3 connecting to: 127.0.0.1:27017/test Sat Mar 10 16:sixteen:45 Error: couldn't connect to server 127.0.0.one:27017 vanquish/mong o.js:86 exception: connect failed
shA.t
fifteen.9k 5 golden badges 49 silverish badges 104 statuary badges
asked Mar 10, 2012 at 15:22
markomarko
10.2k 16 gilded badges 68 silver badges 90 bronze badges
five
11 Answers 11
I found that when I got this error it wasn't because I didn't take my default db path set up up. It was because I was trying to run mongo.exe before running mongod.exe.
answered November 10, 2012 at 19:28
Don HoganDon Hogan
601 1 gold badge 5 argent badges 7 bronze badges
3
-
this is indeed great advice.
Apr 22, 2013 at 0:39
-
This should be the actual reply! That change in one letter is all that is needed. When searching for the exe, cmd auto completes to mongo.exe when tab is pressed. :D
Apr 3, 2014 at 5:56
-
Fixed either - why official docs non telling about this with bold text =)
Apr xxx, 2015 at xx:17
shA.t
15.9k 5 gold badges 49 silver badges 104 bronze badges
answered Mar 10, 2012 at 16:53
JHNJHN
1,008 9 argent badges 12 bronze badges
iv
-
C:\information\db - at that place is the path.. I thought it would create a path in the subfolder of the projection, actually that I detect a much nicer solution.
Mar 10, 2012 at 17:11
-
You can use a custom path, hither's mine : mongod --dbpath /Mongo/db. This starts mongo in c:\mongo and the db is in c:\mongo\db
Mar ten, 2012 at 19:38
-
What almost when creating a web application. What about security and paths?
Mar 11, 2012 at 9:59
-
I installed mongo in e: so I needed to create e:/data/db
Mar 31, 2015 at 14:27
-
As Admin, create directory:
mkdir c:\mongo\data\db -
As Admin, install service:
.\mongod.exe --install --logpath c:\mongo\logs --logappend --bind_ip 127.0.0.1 --dbpath c:\mongo\data\db --directoryperdb -
Start MongoDB:
net start MongoDB -
Start Mongo Trounce:
c:\mongo\bin\mongo.exe
shA.t
15.9k 5 golden badges 49 argent badges 104 bronze badges
answered Nov 19, 2013 at 9:47
rahanrahan
269 3 silver badges ii statuary badges
i
-
Very useful. Thank you.For the people trying this solution, notice that the "As Admin" is very of import ;)
Jul 18, 2017 at ten:06
Follow
-
Create default db folder.
c:\information\db
and also log folder
c:\data\log\mongo.log
or use following commands in control-prompt
mkdir c:\information\log mkdir c:\data\db -
Create config file in bin folder of mongo (or you lot may in save your desired destination).
Add following in text file named "mongod" and save information technology every bit
mongod.cfg
dbpath=c:\data\db
logpath=c:\data\log\mongo.logor use following commands in command-prompt
echo dbpath=c:\data\db>> "mongod.cfg" echo logpath=c:\data\log\mongo.log>> "mongod.cfg" -
At present open command-prompt (ambassador) and run the following command to starting time mongo server
mongod -
Open some other command-prompt (don't close 1st prompt) and run client control:
mongo
Hope this will aid or yous have washed this already.
answered Jul 23, 2015 at 11:27
Sameer JadhavSameer Jadhav
215 1 gold badge 5 silverish badges 11 statuary badges
2
-
+1 For betoken 4. that allows you to monitor what is actually happening if you consummate 1., 2. and iii, with mongo equally a service
October 31, 2019 at 15:08
-
Should we blazon mongod in command prompt every fourth dimension we want to showtime mongo server?
Jan x, 2021 at 14:02
The error occurs when trying to run mongo.exe WITHOUT having executed mongod.exe. The following batch script solved the problem:
@echo off cd C:\mongodb\bin\ start mongod.exe get-go mongo.exe exit
MoonKnight
22.6k 39 gilt badges 139 silverish badges 264 bronze badges
answered October 21, 2014 at 13:46
0
If you are getting these type of errors when running mongod from command line or running mongodb server,
so follow these steps,
- Create db and log directories in C: drive
C:/data/db and C:data/log
- Create an empty log file in log dir named mongo.log
- Run mongod from control line to run the mongodb server or create a batch file on desktop which can run the mongod.exe file from your mongodb installation direction. That way you merely have to click the batch file from your desktop and mongodb will start.
- If y'all have 32-chip system, try using --periodical with mongod control.
answered February 17, 2016 at 17:47
two
-
This answer helped for me quick. "try using --journal with mongod control."
May 31, 2017 at 20:27
-
I had previous version of mongodb 3.0 and later installation version 3.6 I had the same problem. Resolved by removing everything within c:/data/log and run mongod
Jan 9, 2018 at nineteen:47
Create default db folder.
c:\data\db and also log folder
c:\data\log\mongo.log or employ following commands in command-prompt
mkdir c:\information\log mkdir c:\information\db
Igor
xi.8k 4 gilt badges 54 silvery badges 72 bronze badges
answered Jul 16, 2016 at 16:25
you lot tin use beneath command,
mongod --dbpath=D:\domicile\mongodata where D:\dwelling house\mongodata is the information storage path
Amith
6,563 half-dozen gold badges 31 silver badges 45 bronze badges
answered Oct 27, 2013 at 6:fifty
sambasamba
293 ane gold badge 4 silver badges 11 bronze badges
- Go to C:\Program Files\MongoDB\Server\3.four\bin using cmd and write mongod.
- Open some other cmd by right click and run every bit admin point to your monogodb installed directory as mentioned above and then just like write this
mongo.exe - Afterwards that, write
db.examination.save({Field:'Hullo mongodb'})this command will insert a field having name Field and value is Hello mongodb. - After, check the record
db.test.find()and printing enter you will detect the tape that you lot have recently entered.
Zub
816 1 aureate badge 12 silverish badges 22 bronze badges
answered Nov fifteen, 2017 at thirteen:05
1
-
I.e. you have to run
mongodto commencement server andmongoto run client that will use a server.Nov 15, 2017 at 13:xxx
Steps to kickoff a certain local MongoDB instance and to connect to in from NodeJS app:
-
Create
mongod.cfgfor a new database using the pathC:\Program Files\MongoDB\Server\iv.0\mongod.cfgwith the contentsystemLog: destination: file path: C:\Programme Files\MongoDB\Server\four.0\log\mongod.log storage: dbPath: C:\Plan Files\MongoDB\Server\4.0\data\db -
Install mongoDB database past running
mongod.exe --config "C:\Program Files\MongoDB\Server\4.0\mongod.cfg" --install -
Run a particular mongoDB database
mongod.exe --config "C:\Program Files\MongoDB\Server\4.0\mongod.cfg" -
Run mongoDB service
mongo 127.0.0.one:27017/dband !encounter mongoDB bodily connection string to coonect to the service from NodeJS app
MongoDB trounce version v4.0.9 connecting to: mongodb://127.0.0.1:27017/db?gssapiServiceName=mongodb Implicit session: session { "id" : UUID("c7ed5ab4-c64e-4bb8-aad0-ab4736406c03") } MongoDB server version: 4.0.9 Server has startup warnings: ...
answered April 24, 2019 at two:30
RomanRoman
xv.2k 11 gold badges 75 silver badges 79 bronze badges
Poul Kruijt
64.6k 11 gold badges 135 silver badges 134 bronze badges
answered Jan xiii, 2016 at fifteen:51
Not the reply yous're looking for? Browse other questions tagged windows mongodb or enquire your own question.
Source: https://stackoverflow.com/questions/9647561/how-to-connect-to-mongodb-in-windows
Posted by: mooreadezvot.blogspot.com

Bank check if there is something using that port. in cmd: netstat -ano | findstr 27017
Mar 10, 2012 at xv:30
Hey I came across the same problem and solved it past removing .lock file from \data\db binder and everything worked fine from at that place ! :)
Apr 23, 2013 at 10:24
@Muhammad Riyaz how did you remove the lock file on windows 8 im trying \information\db\mongod.lock and information technology's just asking how i want to open the file.
Dec 15, 2013 at eight:20
@phil i simply deleted the .lock file :) to be condom just cut and paste this file somewhere else and check if mongodb works. If it does (i m certain information technology will) yous can dekete this .lock file
December 15, 2013 at xi:48