In macOS Mojave, to prevent your Mac from sleeping follow these simple steps:
Prevent Mac from Sleeping (macOS Mojave)
- Click on the Apple icon on your Mac top menu bar.
- Then select System Preferences option.
- System Preferences window will open, now click on the Energy Saver to open the configuration window for energy saving.
- Now click on the slider (Turn display off after) and drag it to the right to set it to Never. When it will be done, the checkbox to "Prevent the computer from sleeping automatically when the display is off" will be automatically checked. Also, uncheck the checkbox for "Put hard disks to sleep when possible", as shown in the below image:
You have configured your Mac to prevent from sleeping.