EC2 doesn't have a permanent DNS hostname independent of their IP address by default. but there's some work around.
1 - you can get yourself an Elastic IP address and associate it with your EC2 instance, then the DNS name will remain tied to this static address.
2 - you can also place an ALB in front of the EC2, and then the ALB will always have a fixed DNS name, that doesn't change, regardless of the underlying IP addresses or status, and can provide you with much scalability and elasticity.