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
posta 2 mesi fa373 visualizzazioni
7 Risposte
0
Risposta accettata

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

RahulS
con risposta 2 mesi fa
profile picture
ESPERTO
verificato 2 mesi fa
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
ESPERTO
con risposta 2 mesi fa
profile picture
ESPERTO
verificato 2 mesi fa
  • 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
con risposta 2 mesi fa
  • 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
ESPERTO
con risposta 2 mesi fa
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
con risposta 2 mesi fa
0

Enter image description here

RahulS
con risposta 2 mesi fa
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
ESPERTO
con risposta 2 mesi fa
profile picture
ESPERTO
verificato 2 mesi fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande