Search code examples
node.jsmongodbnode-red

MongoError: failed to connect to server in Node-RED


I have a MongoDB running on http://linktomymongo:27017/. When I access this link via a browser I get the "It looks like you are trying to access MongoDB over HTTP on the native driver port." message.

However, when trying to access it through Node-RED I get some errors

Host: linktomymongo Port: 27017 Error:

"MongoError: failed to connect to server [linktomymongo:27017] on first connect"

Host: http://linktomymongo Port: 27017 Error:

"Error: double colon in host identifier"

What am doing wrong? Any help is welcome.

If more information is required please ask :)

Node-RED mongo node (I have tried the link with and without http://: Node-RED mongo config

editing database


Solution

  • Thanks to @derloopkat 's suggestion, I 'ping'ed linktomymongo and it showed the IP address. When I entered that IP address it connected immediately.

    So I guess the node expects a IP address and not an URL