getaddrinfo ENOTFOUND while connecting to SQL Server from Node.js - node.js

I am trying to connect to my SQL Server from Node.js and I am getting this exception:
ERROR: Failed to connect to WAMG9120116\SQLEXPRESS:1433 - getaddrinfo ENOTFOUND WAMG9120116\SQLEXPRESS.
Below is the configuration.
# DATABASE
DATABASE_NAME=AeroPresentationApi
DATABASE_HOST=WAMG9120116\SQLEXPRESS
DATABASE_PORT=1433
DATABASE_USERNAME=XXXX
DATABASE_PASSWORD=XXXXXX
RUN_MIGRATIONS_ON_STARTUP=true
We are connecting to DB via this:-
const sequelize = new Sequelize(
databaseConfig.database,
databaseConfig.username,
databaseConfig.password,
databaseConfig,
);
Can anyone tell me what is going on ?
NOTE: I was able to connect to SQL Server from SSMS using User Name and Password.

Related

Unable to connect mongoDB server with my node.js file, getting MongooseServerSelectionError: connect ECONNREFUSED ::1:27017 constantly

mongod database process running
Local server connected to mongoDB compass
created mongooseTut Folder
npm init
mongoose and node installed
when i try to connect to server by writing node .\index.js, it thorws the error shown in picture, i.e.-MongooseServerSelectionError: connect ECONNREFUSED ::1:27017
P.S.: Have already tried each and every solution mentioned in all relevant replies on stackoverflow.
Tried connecting node.js to mongoDb server and got error MongooseServerSelectionError: connect ECONNREFUSED ::1:27017

Error [MongoError]: failed to connect to server [cluster0.4mocw.gcp.mongodb.net:27017] on first connect

i'm using mongodb atlas for database, and facing this issue in connectivity
it shows, server is running on port 3000
but then shows Error [MongoError]: failed to connect to server [cluster0.4mocw.gcp.mongodb.net:27017] on first connect
please guide me

Can't connect to Mongo Atlas getaddrinfo ENOTFOUND [cluster name]

Using Botkit to create slack bot but can't connect to Mongo Atlas for storage. Nodejs backend. Using Botkit-storage-mongo
Code:
var Botkit = require('botkit');
var BotkitStorage = require('botkit-storage-mongo');
storage = BotkitStorage({ mongoUri: `mongodb+srv://<username>:<password>#<clustername>/test?retryWrites=true&w=majority`})
When I run the code I get this error:
UnhandledPromiseRejectionWarning: Error: MongoError: failed to connect to server [<cluster_name>] on first connect [Error: getaddrinfo ENOTFOUND <cluster_name>
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:60:26) {
name: 'MongoError',
message: 'getaddrinfo ENOTFOUND <cluster_name>'
}]
Dependencies:
"dependencies": {
"botkit": "0.6.21",
"botkit-storage-mongo": "1.0.7",
"mongodb": "^3.5.0"
}
In Mongo Atlas,
my IP address is whitelisted.
Also tested allowing all IPs: 0.0.0.0/0.
Any ideas as to why I cannot connect?
This issue had nothing to do with botkit.
Needed to update connection driver version in mongo atlas dashboard.
Was Node.js 3.0 or later driver version. When I changed that to the Node.js 2.2.12 or later version, that connection string worked.

Failed to connect to mlab Database

I'm trying to connect to my database on mlab through mongodb.
I have cd to mongodb directory, then I run the code and all I get is this error. If I try to connect over localhost it's fine but on real server I get the error below:
./bin/mongo ds151508.mlab.com:51508/dansql -u xx -p xxx
MongoDB shell version v3.6.3
connecting to: mongodb://ds151508.mlab.com:51508/dansql
2018-02-28T09:31:17.748-0700 W NETWORK [thread1] Failed to connect to 34.228.213.238:51508, in(checking socket for error after poll), reason: Connection refused
2018-02-28T09:31:17.749-0700 E QUERY [thread1] Error: couldn't connect to server ds151508.mlab.com:51508, connection attempt failed :
connect#src/mongo/shell/mongo.js:251:13
#(connect):1:6
exception: connect failed

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.

Resources