This question already has an answer here:
I've enabled SSH into my mac mini (late 2012 running OS X 10.9.3), and have the energy saver settings set so that the display sleeps after 10 minutes, and the computer is set to never sleep.
If the mac goes unused for a while, then I try SSH into it, the SSH connection is refused. If I go bang on the keyboard or mouse to wake up the mac, then the SSH connection is accepted and it works.
This appears as though the mac is ignoring my energy saver settings and is in fact sleeping when it shouldn't be.
Is there anything I can do to fix this? Is there anything to look for in console to verify if it is actually sleeping?