somejkuser
somejkuser

Reputation: 9040

Remote MySQL Server not responding

I'm having issues connecting to my AWS EC2 Server holding a MySQL Server.

Here's my Response from mysqli_connect

[email protected] [~/app]# php checkmysqlremote.php Error: Unable to connect to MySQL. Debugging errno: 2002 Debugging error: Connection refused

Here's my netstat -tuplen on the EC2 Server containing the MySQL Server

tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 999 20299 1378/mysqld

As you can see its binding to the 0.0.0.0 address correctly.

I enabled the 3306 port in inbound rules for EC2.

on the server making the request handshake, I ran:

curl -s example.com:3306 >/dev/null && echo Success. || echo Fail.

which resulted in Fail.

I also ran it on the local server instance and it responded with Success.

I also ran nmap on the server making the handshake,

nmap -p 3306 example.com

Nmap scan report for example.com (1.1.1.1)

Host is up (0.048s latency).

PORT     STATE    SERVICE

3306/tcp filtered mysql

Nmap done: 1 IP address (1 host up) scanned in 2.03 seconds

Lastly, I tried adding the following rules in iptables:

iptables -A INPUT -i eth0 -s "example.com" -p tcp --destination-port 3306 -j ACCEPT

and

sudo iptables -I INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT

I don't know what to do at this point.

UPDATE

I tried pinging the EC2 server from the remote server and it did not return anything. At this point i think the issue is with EC2.

Upvotes: 2

Views: 785

Answers (2)

tkingston
tkingston

Reputation: 114

Sounds like the port might not be getting forwarded correctly? One thing to try might be to put an Amazon Elastic Load Balancer in front of the instance. Then you can forward port 3306 for the MySQL connection.

Upvotes: 0

Juned Ahsan
Juned Ahsan

Reputation: 68715

Try adding the follwing GRANT to your user:

GRANT ALL PRIVILEGES ON *.* TO 'user'@'ipadress'

Upvotes: 1

Related Questions