Cannot connect to SQL Server database on Nodejs EC2 server - node.js

I have an EC2 instance running a node server. The pages and routes render fine on the frontend, but when I do anything that requires a call to the api it says failed to connect to XX.XX.X.XXX:1433 (which is my SQL Server database). When I run the app locally (not inside the EC2 instance) it works just fine and connects to the DB. Btw, my local computer is NOT where the SQL Server database is being hosted.
What could the issue be on the instance?
EDIT: TCP is enabled and the Browser part is running in the SQL manager.
EDIT2:This is the error I get every time my EC2 app makes an api call to te database:
ConnectionError: Failed to connect to XX.XX.X.XXX:1433 in 15000ms
But when I do the dame thing on the app from its development computer on localhost it works just fine.

Ok, so, it looks like this is a network connectivity problem. Can you ping the DB server?
ping xx.xx.xx.xx
Second, can you telnet to the port?
telnet xx.xx.xx.xx 1433
My guess is that both of these will fail. So, the question is, why?
Some things to consider:
Is the database server on the public internet? (I hope not, for security reasons.)
Is your client computer on the public internet?
What is the network access path to get from your client machine to the DB server? VPN tunnel? SSLVPN connection? Something else?
I don't have a specific solution for you, but hopefully I gave you some ideas as to where to look. The problem is (almost certainly) not a database problem, but a network connectivity issue.

Related

Socket IO - WSS Throwing error -- remote client, local server

Hi I've been trying to figure this out for some time now. It's kind of hard to explain... Ill try and give some background : I'm trying to create a pwa that can work on WAN and LAN for when offline. ---- So I have a client and server, if I host the client and server both locally I'm having no issues I can connect to one another directly and everything, the socket.io and web socket work great. If I host the client and server both on Heroku they work great as well. The problem comes when I host the client on Heroku and the server locally -- which in the application I'm working on I need this. Im able to still connect to the other user if im using the WAN connection portion but if I try to make the connection using LAN it throws errors. I'm not sure what is going on, I'm still fairly new socketio, websockets, etc... ---- Here is the error I am getting Error Image. Here are my imports on the server - imports-server, how I'm setting up the server - server setup, how I set up the connection on the client -- client setup. Sorry if I wasn't clear on my explanation, thank you for help.

How do I get the exact IP address of my mongodb database?

I am trying to deploy my node app to my Cpanel however the page times out with an error
503 Service unavailable
The website works on Heroku, ngrok and localhost however on my hosting service, it doesn't.
I found out that the issue was due to port 27017 not being open.
On discussing with my hosting providers, they said
"We can open the ports for you but our policy is to open non-standard ports to specific IP's for better security of the server. Is it possible to get the exact IP addresses of the database server you are trying to connect to."
So I'm not familiar with mongodb database having a specific IP address. What could they mean?
To connect to your db, your node app needs a URL something like this.
const url = 'mongodb://hostnameOfMongo.example.com:27017'
Your database's hostname is the stuff after mongodb:// and before :27017.
Open up a shell (a command window) and type
ping -n 1 hostnameOfMongo.example.com
or maybe
ping -c 1 hostnameOfMongo.example.com
It should show you the IP address associated with your mongo server.
(Obvs, put your actual db hostname into the command, not my example.)
It's a little strange that your hosting provider didn't ask for the hostname when you didn't know the IP address. If they were my hosting provider, my confidence in the competence of their support would go down a notch because of that.
And please be aware that running a db in one data center and a node app (or indeed any app that uses the db) in another data center is a formula for poor performance and unreliability. The app and the db work best with a short and private network connecting them. With respect, it doesn't seem likely you have the network engineering chops to make that sort of thing stable and reliable.
Not to mention the security problems with exposing mongodb to the public network. Your hosting service is reluctant to open a port for a very good reason. Read this. Because cybercreeps

Mongo validation fails when connecting to a DB on another computer in lan network

So I have this API app running on my machine, and a MongoServer running on another computer in the same local network.
I have figured that this has to have something to do with the fact that the mongoserver is on another host, because the same Models and Schemas work fine when app is running on same host as server.
I can successfully make GET requests, however when I try to make a POST request my app crashes saying that my schema validation failed.
Do I need to make any extra authentication for that? If yes, how do I go about that?

Amazon Nodejs webserver

I'm getting stuck here, so i have an amazon ec2 (standard redhat server) host up and working. i can connect to it personally no problem, however it cannot be connected to outside of my ip.
I've checked the rules and i have port 80 and 3000 open to 0.0.0.0/0 to be able to communicate, however outside of my computer (and computers in this network) i can not connect.
Everything I've found is about connecting to ssh which works fine, i have no rules in iptables, i haven't dealt much with them before, but since i can connect to the service i don't think its the issue.
summary:
Web server is running, i can connect from my computer to it, and any others in my local network, but nothing outside of it works.
i do have httpd installed as well as a simple forward from the browser to port 3000, however i cant connect to it either from outside my network.
so this is a new one for me, the dns forwarding works in houst, but not outside. so inside and outside here, i can use IP address to connect, but inside only i can connect with my dns lookup. not sure what caused this, but its not an amazon problem at least. going to look at that side.

How to tell on Linux (Lucid) if a connection is coming into the server?

So I have an issue where I am remotely connecting to a Mongodb on my linode box, and I am not longer able to access this DB. I can from my local machine, but when I am on this remote server (where the website runs) it is not working. I am not seeing the connection come into the Mongo logs, so this leads me to believe that maybe it is being intercepted by a firewall?
How can I watch traffic and see if this connection is at least making it to my linode box? I am connecting with Mongoid, so if there is a way to prove no connection there too.
Right now the only error I get is a erb view timeout execution error - not much to go on.
Thanks,
Daniel

Resources