robbie70
robbie70

Reputation: 1615

FailedToParse Bad digit \" \" error message when trying to set-up replica-set in MongoDb

I am getting the following error message when trying to config my replica sets in MongoDb.

enter image description here

the config statement is as follows,

var demoConfig={ _id: "demo", members: [{ _id: 0, host: 'localhost: 30000', priority: 10}, { _id: 1, host: 'localhost: 40000'}, { _id: 2, host: 'localhost: 50000', arbiterOnly: true}] };

I have started 3 MongoDb instances using the following .bat commands. I am using MongoDB v.3.6 and running on Windows 7 desktop.

cd C:\demos\mongodb\mongoData

@REM Primary
start "a" mongod --dbpath ./data/db1 --port 30000 --replSet "demo"

@REM Secondary
start "b" mongod --dbpath ./data/db2 --port 40000 --replSet "demo"

@REM Arbiter
start "c" mongod --dbpath ./data/db3 --port 50000 --replSet "demo"

Why am I getting this error message ? I have tried replacing the ' with ` but it makes no difference I still get the same error.

Upvotes: 0

Views: 1167

Answers (1)

robbie70
robbie70

Reputation: 1615

I found the answer. I needed to remove the space between "localhost:" and the port address i.e. change from 'localhost: 30000' to 'localhost:30000'. So my corrected demoConfig becomes,

var demoConfig={ _id: "demo", members: [{ _id: 0, host: 'localhost:30000', priority: 10}, { _id: 1, host: 'localhost:40000'}, { _id: 2, host: 'localhost:50000', arbiterOnly: true}] };

and this worked for me.

Upvotes: 2

Related Questions