Hmmm. So you are saying that:
you can connect from the ec2 instance to your postgresql instance. you can connect via the web to the fusionauth instance, but it is stuck in maintenance mode.Where is the postgresql instance running? Is it on the same ec2 instance as FusionAuth?
What value are you putting for the hostname?