简体   繁体   中英

AWS communication between two public EC2 instances in same VPC

I have created a VPC. And inside that vpc in same subnet there are two ec2 instances. There is a deployed application on the first one and on the second one there is installed mysql. I have set up the application to connect to the instance with the installed db but with no success. I will copy the security groups configuration and the db configuration. How to make both of these two instance communicate and the application from the first instance start using the db on the second. Both of them have public ip and can ping each other.

DB connection

spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.ddl-auto=update
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://some_ip:3306/demo
spring.datasource.username=root
spring.datasource.password=root

Security groups There are two security groups and both of the are assign to every ec2 instance.

在此处输入图片说明

The added id is the ID of this group.

在此处输入图片说明

EDIT1 - of the second security group
在此处输入图片说明

In your security group you are not allowing port 3306 which the database needs to communicate over.

Install mysql-client on your app server you can use the cli to see if you can connect to the database MySQL server using:

mysql -h mysql://some_ip -u root

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM