I have my mac serving an application on port 80 that I can access within the network, how can I prevent it from sleeping?

Lid Open

Your Mac will sleep if you close the lid.

You need to leave your MacBook lid open for the server to keep responding to requests.

You can set the display to sleep after a period of idle time; this will not affect the server. Only the computer needs to remain awake.


You could use the caffeinate utility from the terminal. To access the terminal, Cmd+Space(Spotlight), then search for Terminal and press Enter. Now, in the terminal type: caffeinate -t 3600 3600 being the number of seconds.


The computer will go to sleep when you close the lid -- unless:

1) You have a mouse/keyboard and display (or virtual display adapter) connected.

OR

2) You install software that allow the system to stay awake even with the lid closed. Some suggested pieces of software from various articles include: Amphetamine, Caffinated. Give one or a few of them a try and see which one works best for you.