I have designed this infrastructure.
ECS SG:
- Ingress: 0.0.0.0/0
- Egress: 0.0.0.0/0
ECS Cluster ASG SG:
- Ingress: 0.0.0.0/0
- Egress: 0.0.0.0/0
Now when I SSH to instance EC2 No 1. Sometimes I have access to MySQL, sometimes no:
ec2-user@EC2No1 $ mysql -u root -hloadbalancerdomain.co.uk -p123456
ERROR 2003 (HY000): Can't connect to MySQL server on 'loadbalancerdomain.co.uk' (110)
ec2-user@EC2No1 $ mysql -u root -hloadbalancerdomain.co.uk -p123456
Welcome to the MariaDB monitor. Commands end with ; or \g.
ec2-user@EC2No1 $ mysql -u root -hloadbalancerdomain.co.uk -p123456
ERROR 2003 (HY000): Can't connect to MySQL server on 'loadbalancerdomain.co.uk' (110)
ec2-user@EC2No1 $ mysql -u root -hloadbalancerdomain.co.uk -p123456
ERROR 2003 (HY000): Can't connect to MySQL server on 'loadbalancerdomain.co.uk' (110)
ec2-user@EC2No1 $ mysql -u root -hloadbalancerdomain.co.uk -p123456
Welcome to the MariaDB monitor. Commands end with ; or \g.
Now I do the modification for the infrastructure:
I have no access to MySQL from instance 1, I have access to MySQL from instance 2
Instance 1
ec2-user@EC2No1 $ mysql -u root -hloadbalancerdomain.co.uk -p123456
ERROR 2003 (HY000): Can't connect to MySQL server on 'loadbalancerdomain.co.uk' (110)
ec2-user@EC2No1 $ mysql -u root -hloadbalancerdomain.co.uk -p123456
ERROR 2003 (HY000): Can't connect to MySQL server on 'loadbalancerdomain.co.uk' (110)
ec2-user@EC2No1 $ mysql -u root -hloadbalancerdomain.co.uk -p123456
ERROR 2003 (HY000): Can't connect to MySQL server on 'loadbalancerdomain.co.uk' (110)
Instance 2
ec2-user@EC2No2 $ mysql -u root -hloadbalancerdomain.co.uk -p123456
Welcome to the MariaDB monitor. Commands end with ; or \g.
ec2-user@EC2No2 $ mysql -u root -hloadbalancerdomain.co.uk -p123456
Welcome to the MariaDB monitor. Commands end with ; or \g.
Target group:
Task definition network mode: HOST
Question
How Can I fix this?
The problem does not exists with the awsvpc network mode for task definition, but I need to scale instances up to use this mode.