0

I'm not using AWS RDS, only using AWS EC2.

I uploaded my data to the MySQL server on AWS EC2 Ubuntu 20.04 on port 3306.

Also, at that ubuntu, I am running my Node.js web server on port 3000.

But, the web server can't reach the MySQL server. They always say

err :  { Error: connect ECONNREFUSED 127.0.0.1:3306
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1107:14)

enter image description here The above picture is my inbound rule now.

I checked my data is in MySQL server using some query...

Is there anything to do more?

If you need more information about my setting or something, please let me know.

3
  • You have both ms mql and nodejs running in same EC2 instance? Commented Mar 14, 2021 at 9:32
  • If your MySQL is on localhost with your app, then security groups are irrelevant. Can you use mysql cli to connect to your db? Commented Mar 14, 2021 at 9:59
  • Yes, I am both running mql and nodejs in the same EC2 instance. Commented Mar 14, 2021 at 19:57

1 Answer 1

1

maybe the following steps can help you to resolve this:

  • make sure that it runs locally first on MySQL docker container: create database name, a user with sufficient rights in MySQL, connect to it applying username, password, URL, port, and other options.
  • document those steps and try the exact same steps on ec2, I see you already exposed the 3306 port, that is good. Btw. I would try with heroku with node first, because there is more documentation with Heroku CL and cleardb, which is the addon for MySQL and it is free :)
  • btw. normally a database should be placed in a private subnet and access should only be allowed via a nat-instance / nat-gateway, so that only requests from the public subnet are permitted, but the database can still download patches via nat, just to keep the best practice in mind ;)
Sign up to request clarification or add additional context in comments.

1 Comment

I'm not using AWS RDS, only using AWS EC2. I uploaded my data to the MySQL server on AWS EC2 Ubuntu 20.04 on port 3306. Also, at that ubuntu, I am running my Node.js web server on port 3000. But, the web server can't reach the MySQL server. They always say

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.