Error: "Double colon in host identifer"
Asked Answered
P

5

14

I am trying to connect to a database that I have hosted at MLab. I am using the StrongLoop API. I've placed the config information for my hosted databases into my datasources.json and config.json files, but whenever I run the directory with npm start, I get throw new Error ('double colon in host identifier';) at api\node_modules\mongodb\lib\url_parser.js:45.

I have also made sure to install the loopback-connecter-mongodb npm package.

Here is a snippet of datasources.json (without the actual database details, of course):

{
  "db": {
    "name": "db",
    "connector": "mongodb",
    "host": "ds047355.mlab.com",
    "database": "dbtest",
    "username": "user",
    "password": "fakepassword",
    "port": 47355
  }
}

Here is the config.json file:

{
  "restApiRoot": "/api",
  "host": "ds047355.mlab.com",
  "port": 47355,
  "remoting": {
    "context": {
      "enableHttpContext": false
    },
    "rest": {
      "normalizeHttpPath": false,
      "xml": false
    },
    "json": {
      "strict": false,
      "limit": "100kb"
    },
    "urlencoded": {
      "extended": true,
      "limit": "100kb"
    },
    "cors": false,
    "errorHandler": {
      "disableStackTrace": false
    }
  },
  "legacyExplorer": false
}

Got any ideas?

Pompous answered 24/3, 2016 at 17:44 Comment(3)
You have the host and the port inside the config.json as the data source ones, and this is not their place. the config should include the Host and Port of where you want loopback to run the node server, which locally could be 0.0.0.0:3000Exuberate
Thanks for your help Rabee! I added the host as 0.0.0.0 in config.json and added the port as 3000, but I still get the same error...Pompous
It also may be when you use : or / in your mongodb passwordMenadione
F
7

I finally solved my problem resulting in this error. It was reading one of my server URLs as http://0.0.0.0/:8080 but was fixed when I changed to http://0.0.0.0:8080

Hope this helps you or someone else.

Filler answered 15/6, 2016 at 14:33 Comment(1)
what if ur connecting to mlabDiplostemonous
R
3

Make sure you don't have weird characters in it (e.g. @#$%^:,/.), I had some and got that error message. Changed the password to an alphanumeric one and works flawlessly.

Rapine answered 18/8, 2017 at 17:56 Comment(0)
A
2

It generally happens when you provide wrong information about your URL. In my case, i provided the url.com/db_name instead of url.com

Amalgamate answered 4/2, 2017 at 9:53 Comment(0)
W
2

I HAVE THE SOLUTION!

During my times with self hosting on Ubuntu, I was unable to load my settings.json. For some reason, I had to remove all white space out of it.

So I finally move over to Meteor Galaxy, follow their tutorial to the letter, and get all sorts of mongo errors. So what the heck, lets remove all the white space, right?

tldr; Put your entire setting.json on one line

check www.skyrooms.io to see running :D

Willow answered 2/3, 2017 at 20:21 Comment(0)
D
1

I got the same error and finally solve it. My previuos datasource json :

"db": {
   "host": "mongodb://127.0.0.1",
   "port": 27017,
   "url": "",
   "database": "dbname",
   "password": "12345",
   "name": "db",
   "user": "admin",
   "connector": "mongodb"
}

Then, i filled the url value like this :

"db": {
   "host": "mongodb://127.0.0.1",
   "port": 27017,
   "url": "mongodb://127.0.0.1:27017/dbname",
   "database": "dbname",
   "password": "12345",
   "name": "db",
   "user": "admin",
   "connector": "mongodb"
}
Durst answered 18/10, 2017 at 13:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.