It's working fine. All of a sudden it started throwing 504 Timeout error. In SSH it was showing ubuntu upgrade warning, I've installed the necessary and upgraded correctly hoping that it would not throw errors anymore. But still the issue persist. I've checked the inbound rules in AWS, all good for port 80,443 and 22. I dont have SSM agent installed in AWS and I dont find the right guide to install that.
Which could have possibly gone wrong?
Based on the comments.
The issue was that instance was restarted. Consequently, the public IP provided by AWS has changed:
We release your instance's public IP address when it is stopped, hibernated, or terminated. Your stopped or hibernated instance receives a new public IP address when it is started.
To overcome this issue in the future, you can attach an elastic IP (EIP) to your instance. EIP persists between restarts and is free as long as it is attached to a running instance.