mysql port running on Private ec2 is not responding to the port 3306

0

Hello, I have a public EC2 running on Windows (using as a bastion host to connect to the private ec2 only) is unable to reach to the port 3306 running on Linux EC2 in private subnet. I have opened the the rule "All traffic" from Public bastion host and its security group for private ec2. Able to paping port 22/80/443 etc but only mysql 3306 is not responding. Also confirmed that port 3306 is running locally on private ec2 running on Linux. Just for information this Linux instance was launched from CIS Benchmark image.

RahulS
已提问 2 个月前373 查看次数
7 回答
0
已接受的回答

thank you all. I was able to fix the issue. Turned out that iptable service was enabled and upon disabling it, issue resolved,

RahulS
已回答 2 个月前
profile picture
专家
已审核 2 个月前
0

Port 3306 may only be bound ro 127.0.0.1 and not * OR the IPV6 address only. It could just not be running either.

check with netstat -an and look for port 3306

profile picture
专家
已回答 2 个月前
profile picture
专家
已审核 2 个月前
  • Please see output

0

The ec2 and security groups are correct. I have only allowed 22/443/80 on incoming of Windows Ec2.

Means From Windows Bastion traffic is allowed to Linux on port 80/443/22

RahulS
已回答 2 个月前
  • Does that mean you are allowing 3306 in the inbound rules for your Linux instance's security group?

0

Hello.

Can I access 3306 on a Linux instance using the "telnet" command from a Windows instance?

telnet Linux-Instance-IP 3306

Also, what kind of error occurs when connecting?
For example, if a timeout error occurs, it is possible that the EC2 security group or OS firewall is denying access to 3306.
By the way, if you can log in to MySQL from a Linux instance, use the following command to allow root user access from all hosts.

rename user root@'localhost' to root@'%';
profile picture
专家
已回答 2 个月前
0

When I do telnet to the linux ip with port 3306 it says, Could not open connection to the host, on port 3306: Connect failed.

Also rename user root@'localhost' to root@'%'; didn't work.

But attached is the output from the netstat -lntp command shows port 3306 is not on listening mode.

Enter image description here

RahulS
已回答 2 个月前
0

Enter image description here

RahulS
已回答 2 个月前
0

In your netstat output your not even listening on port 80 or 443 and you said you were. To me it sounds like your security groups are not correct or your trying to connect to the wrong EC2

profile picture
专家
已回答 2 个月前
profile picture
专家
已审核 2 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则