Stale endpoint naming issues may occur when shutting down and restarting the server instance from the AWS Management Console due to AWS changing the hostname of the instance.
It is possible to turn off this server name change feature using the EC2Launch v2 agent which is installed on the server instance:
In this tool, uncheck "Set Computer Name" in the General tab and click Save: