There are quite a few different reasons (already posted) in which i've seen this error obtained. Nonetheless I ran into this issue with a client recently in which none of the posted articles accounted for. The customer was attempting to load the Ambari UI and received the "unable to connect to Ambari server. Confirm ambari server is running and you can reach ambari server from this machine" error.
We checked Iptables which were turned on, but when disabled the issue persisted.
We checked Ambari Server permspace but the amount specified was sufficient.
We checked SElinux and it was disabled.
We were finally able to load into the Ambari Server after checking "tripwire":
ps -ef |grep tripwire
Once tripwire was disabled, we were successfully able to login. More information regarding tripwire can be found here: