Error: failed to connect to [undefined:27017] - node.js

i get this error when trying to connect to a db setup on mongolab
Error: failed to connect to [undefined:27017]
however, my connection URI is:
'user' : 'mongodb://dbuserNameString:dbPasswordString#ds027789.mongolab.com:27789/db1'
so where does undefined come from?

As you can see in the tutorial you mentioned, you have to use the url instead of user, the change should be:
'url' : 'mongodb://dbuserNameString:dbPasswordString#ds027789.mongolab.com:27789/db1'

Related

Error: Failed to connect to MongoDB. Are you sure your configured Mongo instance is running? When lifting sails

Hi guys im receiving an error
Error: Failed to connect to MongoDB. Are you sure your configured Mongo instance is running? Error details: { [MongoError: failed to connect to server on first connect] name: 'MongoError', message: 'failed to connect to server on first connect' }
I'm using a previous version of Sails since that its the version that they are currently using
Sails ~0.12.4
nodejs -v 4.2.6
npm -v 3.5.2
error: A hook (`orm`) failed to load!
error: Error: Failed to connect to MongoDB. Are you sure your configured Mongo instance is running?
Error details:{ [MongoError: failed to connect to server [192.168.2.45:27017] on first connect] name: 'MongoError',
failed to connect to server [192.168.2.45:27017] on first connect]
name: 'MongoError', message: 'failed to connect to server [192.168.2.45:27017] on first connect' }
My config/connection.js looks like this
module.exports.connections = {
localDiskDb: {
adapter: 'sails-disk'
},
mongodbServer: {
adapter: 'sails-mongo',
host: '192.168.2.45',
port: 27017,
user : 'dbAdmin',
password : 'hiveslab',
database: 'sauce_db'
},
};
I'm stuck on this for a day and I'm pretty much of a newbie here. Hopefully you guys can lead me to the right resolution. Thank you in advance have a good day.

Dialogflow NodeJS library issue

I'm working on a dialogflow POC where I'm trying to invoke the v2 API provided by DialogFlow. While trying the NodeJS code example provided here, I'm getting the below error
{ Error: EHOSTUNREACH undefined: Getting metadata from plugin failed with error: request to https://www.googleapis.com/oauth2/v4/token failed, reason: connect EHOSTUNREACH 0.0.38.172:80 - Local (192.168.0.103:51468)
at Object.callErrorFromStatus (/Users/devuser/Development/workspaces/df-poc/node_modules/#grpc/grpc-js/build/src/call.js:30:26)
at Http2CallStream.call.on (/Users/devuser/Development/workspaces/df-poc/node_modules/#grpc/grpc-js/build/src/client.js:96:33)
at Http2CallStream.emit (events.js:203:15)
at process.nextTick (/Users/devuser/Development/workspaces/df-poc/node_modules/#grpc/grpc-js/build/src/call-stream.js:75:22)
at process._tickCallback (internal/process/next_tick.js:61:11)
code: 'EHOSTUNREACH',
details:
'Getting metadata from plugin failed with error: request to https://www.googleapis.com/oauth2/v4/token failed, reason: connect EHOSTUNREACH 0.0.38.172:80 - Local (192.168.0.103:51468)',
metadata: Metadata { internalRepr: Map {}, options: {} } }
I have imported GOOGLE_APPLICATION_CREDENTIALS and point the environment variable to the credentials. The invocation works fine if I try the REST API route with the Authorization header.
Kindly let me know if there is something which I'm missing here.
This means EHOST (the remote host of the files you are requesting) are unreachable. They are either down, or your computer cannot access them due to some other restriction, such as location, which can be solved with a VPN.

MongoError: js:237:13 connect failed [localhost:27017]

I would like to install Mongodb on IntelliJ (already with Angular and Node.js). I installed MongoDB and changed my environment variables. I use Windows 10. When I try the command line : "mongo dbs show", I get this error :
MongoDB shell version v3.4.10 connecting to:
mongodb://127.0.0.1:27017/dbs 2017-11-20T16:59:43.003+0100 W NETWORK
[thread1] Failed to connect to 127.0.0.1:27017 after 5000ms
milliseconds, giving up. 2017-11-20T16:59:43.003+0100 E QUERY
[thread1] Error: couldn't connect to server 127.0.0.1:27017,
connection attempt failed : connect#src/mongo/shell/mongo.js:237:13
#(connect):1:6 exception: connect failed
In order to fix it, I tried the instructions of related posts, that is to say :
-Create a data directory in "MongoDB\Server\3.4\data"
-Change the directoy "mongod --dbpath=..."
-Change the allowed port to 27017 thank to "add --port 27017"
I did those operations but it doesn't solve the problem. Would you know how to fix it ? I thank you very much in advance !

MongoLab - How to resolve ECONNREFUSED

I have a NodeJS application using MongoDB as the database. I'm using mongoose for mongodb related activities.
I have an account in MongoLab and I use that for my database related activities of my application.
When trying to connect to MongoLab as below from nodejs
mongoose.connect("<db_url_with_username_password>", function(err) {
if(err)
{
console.log("Error is "+err);
throw err;
}
});
It's logging the following line
Error is MongoError: connect ECONNREFUSED 54.161.65.217:19058
I thought the server could be down, hence I checked the website online, it's working perfectly.
I pinged the server with the following
ping 54.161.65.217
and it's working fine.
64 bytes from 54.161.65.217: icmp_seq=0 ttl=28 time=271.396 ms
64 bytes from 54.161.65.217: icmp_seq=1 ttl=28 time=268.824 ms
However, When I'm trying to connect using the mongo command to connect, it's failing
mongo 54.161.65.217:19058/<db_name> -u <username> -p <password>
MongoDB shell version: 3.2.1
connecting to: 54.161.65.217:19058/arogyavath
2016-03-14T10:28:27.200+0530 W NETWORK [thread1] Failed to connect to 54.161.65.217:19058, reason: errno:61 Connection refused
2016-03-14T10:28:27.201+0530 E QUERY [thread1] Error: couldn't connect to server 54.161.65.217:19058, connection attempt failed :
connect#src/mongo/shell/mongo.js:226:14
#(connect):1:6
exception: connect failed
I looked around and found the following questions which could be similar to mine
Node.js Error: connect ECONNREFUSED
ECONNREFUSED error when connecting to mongodb from node.js
But the answers I found there didn't help me fix the issue.
Could the server ip address be blocked from my network or something? How do I fix this?
I would be very glad if someone can point me in the right direction. Thanks in Advance.

How to connect to DB2 SQL database with node JS?

For linux, one can use the API page found here, and connecting is straight forward. For OS X, one will run into the error when trying to connect to an existing DB2 database:
{ [Error: [IBM][CLI Driver] SQL1042C An unexpected system error occurred. SQLSTATE=58004 ] error: '[node-odbc] SQL_ERROR', message: '[IBM][CLI Driver] SQL1042C An unexpected system error occurred. SQLSTATE=58004\n', state: 'HY000' }
Does anyone know how to fix this problem?
The latest answer on this issue gives you the answer:
export DYLD_LIBRARY_PATH=/Users/.../<project_folder>/node_modules/ibm_db/installer/clidriver/lib/icc
node app.js
You have to do this every time you enter the shell, so you may as well put this in your .profile or .bash_profile.

Resources