Anjil Dhamala
Anjil Dhamala

Reputation: 1622

errmsg bad digit "\" while parsing port 30000 code 93

So, I am following a MongoDB tutorial on Pluralsight and I've been able to create a, b and c database on the same machine. After a successful creation of all three, I run mongo on port 30000 which is the port for my primary database.

>mongo --port 30000

It displayed connecting to the port and then I typed

db.getMongo()

It made a connection to the address

And I typed in a javascript object as done by the guy on Pluralsight which goes

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

After I pressed enter, I tried to run rs.initiate with the file democonfig

rs.initiate(democonfig)

This is the error I get:

{ "ok" : 0, "errmsg" : "Bad digit \" \" while parsing 30000", "code" : 93 }

This is how my replicaSet bat file looks like.

cd \Pluralsight\

md \Pluralsight\db1
md \Pluralsight\db2
md \Pluralsight\db3

@REM Primary
start "a" c:\MongoDB\bin\mongod.exe --dbpath ./db1 --port 30000 --replSet "demo"

@REM Secondary
start "b" c:\MongoDB\bin\mongod.exe --dbpath ./db2 --port 40000 --replSet "demo"

@REM Arbiter
start "c" c:\MongoDB\bin\mongod.exe --dbpath ./db3 --port 50000 --replSet "demo"

Upvotes: 6

Views: 2684

Answers (3)

Venkata.Mutyala
Venkata.Mutyala

Reputation: 695

I ran into the same issue on Pluralsight's: "Introduction to MongoDb" tutorial. Below is what I used in the "configuring a replica set" section:

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

Upvotes: 10

Vijay
Vijay

Reputation: 21

I just removed space between localhost: and port number (localhost:30000) and the same thing for other 2 hosts. It worked fine.

Upvotes: 2

Anjil Dhamala
Anjil Dhamala

Reputation: 1622

Solved it! Just removed all the spaces in between the javascript code and it ran fine.

Upvotes: 7

Related Questions