1
votes

We deployed the NodeJS web service on DigitalOcean and connect to MySQL database on Amazon RDS. i can use Navicat Premium to remote to MySQL RDS and also works fine with NodeJS localhost (it means my application on localhost can connect to RDS database)

But when i deployed my app to DigitalOcean server. It cannot connect to MySQL RDS. The connect was timed out.

I use command to view opening port:

iptables -L

And the result is:

Chain INPUT (policy ACCEPT)
target prot opt source destination

ACCEPT tcp -- anywhere anywhere tcp dpt:3000
ACCEPT tcp -- anywhere anywhere tcp dpt:mysql
ACCEPT tcp -- anywhere anywhere tcp dpt:3000
ACCEPT tcp -- anywhere anywhere tcp dpt:mysql
ACCEPT tcp -- anywhere anywhere tcp dpt:mysql

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

ACCEPT tcp -- anywhere anywhere tcp dpt:mysql

I see output and input also opened for port 3306. But NodeJs still cannot connect. The problem is DigitalOcean droplet does not open port 3306 and NodeJS application cannot connect to outside via this port.

(P/S: Amazon RDS also opened all ports and anywhere for IP)

Please help me, thanks

1
If you SSH into the droplet and run 'mysql -h <aws db>' from there, are you able to connect?JoshWillik
@JoshWillik cannot connect and also cannot ping them, i don't know why. But my droplet does not block any IPKevin Vo
Is the connection being denied on the AWS side?JoshWillik
@JoshWillik hi, i sent the question to DigitalOcean team. They said they don't open port 3306. So it's so difficult to word for production. Maybe i will move the server to amazon EC2. Thanks for your comments :)Kevin Vo
@JoshWillik i found the issue. After RDS is set up, it only allows for my IP. So we should go to Security Group and change the IP for RDS to anywhere or to NodeJS server. It works now :)Kevin Vo

1 Answers

3
votes

After Amazon RDS is set up, it only allows connections from my IP address.

To fix this, go to the Security Group settings and allow connections to RDS from anywhere or just the NodeJS server in question.