Hi I am trying to host PHP code in AWS EC2(Windows) server on IIS. I am able to host the php webpages but the issue is the the webpages are not able to communicate to AWS RDS. PHP Code for Database:
<?php
$con=mysqli_connect("mysqldatabase.xxxxxxxxxx.ap-south-1.rds.amazonaws.com", "admin", "xxxxxxx", "detsdb", "3306");
if(mysqli_connect_errno()){
echo "Connection Fail".mysqli_connect_error();
}
?>
I am using default VPC rule and in both RDS and EC2 Security Group(Both Inbound and Outbound) I have opened all traffic as well as Opened SG id with port 3306 with each other.
**Error on Webpage: Connection FailServer sent charset unknown to the client. Please, report to the developers **
When I am trying the same code from my personal computer, I am able to communicate with RDS. I am using Wamp server to communicate and host it locally.
written a simple code to test the functionality that's also working:
<?php
$con = mysqli_connect("mysqldatabase.xxxxxx.ap-south-1.rds.amazonaws.com", "admin", "xxxxx", "detsdb", "3306");
if($con){
echo "Connection Success";
}
else
{
echo "Error";
}
?>
Please help me on this.
Edit: Screenshot attcahed for both Ec2 and RDS SG
Publicly Accessible = True
? Is the EC2 instance in a public or a private subnet? Does the VPC have a NAT Gateway? – John Rotenstein