This article explains how to prevent your MacBook from sleeping when the lid is closed.
You'll need to change a few settings to stop your MacBook from going to sleep with the lid closed.
ClickSystem SettingsorSystem Preferencesfrom the Apple menu in the upper left corner.
ClickLock Screen, then select the menu next toTurn display off on power adapter when inactive.PickNever.
If you don't see that option, go toBattery>Power Adapterinstead, then select the slider and move it toNever.
ClickBatteryfrom the menu, then chooseOptions. Switch on the toggle next toPrevent automatic sleeping on power adapter when the display is off.
In some versions of macOS, this option is in thePower Adaptermenu and it's calledPrevent computer from sleeping automatically when the display is off.
Plug your MacBook into power.
Connect your MacBook to an external monitor using an adapter if necessary.
You can now close your MacBook without the external display turning off. Note that the display on the MacBook itself does turn off, just not the external monitor.
If you want to use your MacBook in this configuration permanently, you can use the Mac sleep scheduler to have it sleep and night and wake up in the morning automatically.
Your MacBook sleeps when you close the lid for several reasons, depending on whether it's plugged in. When plugged in, it sleeps to help conserve energy and allow it to charge more quickly, as it uses much less power while asleep. When running on battery power, it sleeps when you close the lid to conserve battery power. Since you typically don't need to use your MacBook when the lid is closed, the default setting is for the display to turn off and the MacBook to sleep whenever the lid is closed.
The most common reason to want to keep a MacBook from sleeping when the lid is closed is if you're going to use it with an external monitor and keyboard. Apple makes that reasonably easy if you follow the instructions provided in the previous section.
Apple only provides you with one way to keep your MacBook from sleeping with the lid closed: tweak the energy-saver settings, connect the battery charger, and plug in an external monitor.
No option in the battery or energy-saving settings allows a MacBook to remain awake with the lid closed if an external monitor isn't plugged in. That means you'll have to install a third-party app, like Amphetamine, to keep your MacBook from sleeping without plugging in an external monitor.
SelectSystem Settings>Battery>Options. Turn onPrevent automatic sleeping on power adapter when the display is off. Also, go toSystem Settings>Lock Screen>Turn display off on power adapter when inactive, and chooseNeverto keep your Mac from sleeping.
If you don't want your MacBook to go into sleep mode after a certain amount of time on battery power, turn off this setting. Go to System Settings > Lock Screenand select the menu next toTurn display off on battery when inactive; change it toNever.
Ensure the setting for turning off the display is active. Go to System Settings> Lock Screenand review those settings. Also, in theBatterymenu, chooseOptionsand disable thePrevent automatic sleepingtoggle. Also, check Bluetooth wake settings:Bluetooth > Advanced > uncheck Allow Bluetooth devices to wake this computer.