Connection with SQL Server 2014 with node js - node.js

I am unable to connect to my SQL Server 2014 from node server.
I get this error:
Failed to connect to 192.168.1.3,2207:2207:1433 - getaddrinfo ENOTFOUND 192.168.1.3,2207:2207'
TCP port also enabled but same issue

By using knex i resolve this problem
connection: {
server : 'IP Address',
user : 'sa',
password : '******',
database : '*****',
options: {
port: 14831
}
}

Related

connect() failed (111: Connection refused) while connecting to upstream Nodejs Elastick Beanstalk

I have a log nodejs backend code here and it runs on port 8080.
process.env.PORT = 8080 in the environment varisbles.
var port = process.env.PORT;
app.listen(port, ()=> {
console.log("Port is", port);
})
It connects to the databse as I see the output in the log file :
Port is 8080
I get an error in the log file with the following.
/var/log/nginx/error.log
----------------------------------------
connect() failed (111: Connection refused) while connecting to upstream, client: 777.77.7.777, server: , request: "GET / HTTP/1.1", upstream: "http://111.1.1.1:8080/", host: "666.66.66.666"
Does anyone know why it errors?
Should the host: be my elastic beanstalk url by any chance?
If you need any additinal info let me know!

Access database on Server with localhost node Project

I have bought a VPS for my website. I have built a small project with vue and node.
In this I used postgresql that is working fine on localhost.
I want to change my database from localhost to the server database where I have installed postgres and made a database and table.
My db.js file looks like this:
const Pool = require('pg').Pool;
const pool = new Pool({
user: "postgres",
password: "root",
database: "todo_database",
host:"45.111.241.15",
port: 5432
});
module.exports = pool;
Then I tried to send form data from the localhost vue page and it gave the following error:
error connecting db Error: connect ECONNREFUSED 45.111.241.15:5432
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '45.111.241.15',
port: 5432
I do not have much knowledge about this and how to solve this.
Can you please guide me what should I do to connect with my server db?
I follow these steps and it worked:
edit your /etc/postgresql/9.1/main/postgresql.conf and change
Connection Settings -
listen_addresses = '*' # what IP address(es) to listen on;
In /etc/postgresql/10/main/pg_hba.conf
IPv4 local connections:
host all all 0.0.0.0/0 md5
Now restart your DBMS
sudo service postgresql restart
Now you can connect with
psql -h hostname(IP) -p 5432 -U postgres

Solved. Q&A: MongoDB MongoNetworkError: failed to connect to server. server is remote server

mongoose connect to MongoDB fails. But mongo command line can connect to MongoDB.
Code:
var mongoose = require('mongoose');
mongoose.connect('mongodb://192.168.92.131/test', {useNewUrlParser: true});
Result:
(node:6559) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [192.168.92.131:27017] on first connect [Error:
connect EHOSTDOWN 192.168.92.131:27017 - Local (192.168.92.1:60222)
at internalConnect (net.js:835:16)
at defaultTriggerAsyncIdScope (internal/async_hooks.js:301:12)
at net.js:926:9
at processTicksAndRejections
(internal/process/task_queues.js:75:11) {
name: 'MongoNetworkError', errorLabels: [Array],
[Symbol(mongoErrorContextSymbol)]: {}
My MongoDB is installed in a virtual machine running Ubuntu OS. I searched for a solution, but I failed to find a clean solution.
I found a feasible solution to share:
Troubleshooting process
Run mongo command line. Connection ok.
MongoDB does not have access control (user/password) by default. So my code is ok.
IP problem? Mongodb did not start on 192.168.92.131
Google: start mongodb using external ip
Found a solution: https://www.shellhacks.com/mongodb-allow-remote-access/
ether#ubuntu_ether:~$ sudo nano /etc/mongod.conf
No external IP address. So add ip address in mongod.conf
…....
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1, 192.168.92.131
ether#ubuntu_ether:~$ sudo service mongod restart
Run again:
var mongoose = require('mongoose');
mongoose.connect('mongodb://192.168.92.131/test', {useNewUrlParser: true});
OK!!!

ssh2 timed out while waiting for handshake in nodejs

I am trying to upload a file using ssh in my nodejs application, while trying, I am getting error as "connection error: timed out while waiting for handshake". gave connection setting as,
....
}).connect({
host: 'hostname without http',
port: 22,
debug: console.log,
readyTimeout: 99999,
username: 'name',
password: 'password'
});
If I upload manually to the server it is working fine with the given hostname, username and password.

nodejs - cassandra-client error: All connections are unhealthy

I keep getting this error when I try to retrieve/update data from cassandra using cassandra-client.
{ [Error: All connections are unhealthy.]
connectionInfo:
{ host: 'localhost',
port: 9160,
keyspace: 'keyspace1',
user: undefined,
pass: undefined,
use_bigints: false,
timeout: 4000,
log_time: false,
staleThreshold: 10000 } }
Haven't got a clue as to what this error means.
The error indicates that your client is not able to connect to the specified server on localhost port 9160.
Since this is localhost you can most likely exclude any firewall problems.
What you can do
1. Check if your server is running after all
This should show you one or more processes ( except the grep process you're just executing
ps aux | grep "cassandra"
2. Verify the port
# telnet localhost 9160
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
Bad.. This would indicate that something with your configuration might be wrong. In my case I simply don't have a cassandra server listening to port 9160 ( running at all )
3. Check your logfile
By default casandra writes into the folder /var/log/cassandra/
If anything is wrong with the server, you'll most likely have some more information available in there, might even show a problem related to your nodejs client
4. Try another client for debugging
http://wiki.apache.org/cassandra/GettingStarted#Step_4:_Using_cassandra-cli

Resources