I’m facing an issue where I cannot start my MongoDB server on Windows 10. Here’s what happens:
- Error in MongoDB logs:
{"t":{"$date":"2024-10-21T18:23:54.163+05:30"},"s":"I", "c":"CONTROL", "id":23285, "ctx":"thread1","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
The last line in the logs indicates an unhandled exception:
{"t":{"$date":"2024-10-20T00:22:39.445+05:30"},"s":"F", "c":"CONTROL", "id":23137, "ctx":"initandlisten","msg":"*** immediate exit due to unhandled exception"}
This is a link to the all log file:
Link to log file.
-
Connection error in my Node.js application:
connect ECONNREFUSED 127.0.0.1:27017
-
Windows Service error when trying to start MongoDB:
Error 1067: The process terminated unexpectedly.
-
Checked
mongod.cfg
for correct configuration. MydbPath
andlogPath
are set as follows:storage: dbPath: C:Program FilesMongoDBServer8.0datadb systemLog: destination: file path: C:Program FilesMongoDBServer8.0logmongod.log
-
Verified the
C:datadb
directory exists and has the correct permissions. -
Ran MongoDB with
--repair
:mongod --repair --dbpath C:datadb
The repair completes, but MongoDB still won’t start.
-
Checked for port conflicts on
27017
using:netstat -ano | findstr :27017
Nothing else is using this port.
-
Reinstalled MongoDB and ensured that all previous MongoDB data and configuration files were deleted before reinstalling.
-
Tried running
mongod.exe
manually from the command line with administrative privileges. The error still persists. -
Checked Windows Event Logs for more details but couldn’t find any additional information.
Mongoose Connection Code:
const mongoose = require('mongoose');
mongoose.connect("mongodb://127.0.0.1:27017/mydatabase");
System Info:
- OS: Windows 10 (64-bit)
- MongoDB Version: 8.0
- Node.js: v20.18.0
Request:
How can I resolve Error 1067 and get MongoDB to start correctly on my machine? Any suggestions on what else I should check or try?
You have set
storage:
dbPath: C:Program FilesMongoDBServer8.0datadb
That means, you must verify the C:Program FilesMongoDBServer8.0datadb
directory exists and has the correct permissions.
C:datadb
is just the default if you don’t specify any storage.dbPath
Tried running
mongod.exe
manually
That’s something different, because without a config file, it uses default parameters. You would need mongod.exe --config "C:Program FilesMongoDBServer8.0binmongod.cfg"
BTW, it is maybe not the smartest choice (or at least not so common) to put data and logs under C:Program Files...
2