Error: “Double colon in host identifer”

僤鯓⒐⒋嵵緔 提交于 2019-12-08 15:09:19

问题


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?


回答1:


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.




回答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




回答3:


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




回答4:


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"
}



回答5:


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.



来源:https://stackoverflow.com/questions/36206686/error-double-colon-in-host-identifer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!