Mac not returning to Sleep Mode: Causes and Workaround

My Mac doesn't always return to Sleep Mode. I eventually managed to understand the causes and find a perfect workaround.


I've disabled everything that might wake the machine, so now I can only wake it with the power button. Even so, it woke up approximately 10 times during the night, and 3 of those times it didn't go back to sleep. As a result, I regularly had to get up several times a night to manually put the machine back to sleep, which seriously degraded my sleep quality.

My previous Mac, a Mac Pro did the same, this is why I thought it's somewhat user-specific issue.


  • Apple Support was not prepared to deal with this issue but later they encouraged me to share my solution, so here I am.
  • The solution came when an AI, prompted to be an Apple system engineer, analyzed log entries and gave explanation even about the technological background.
  • It turned out that disabling everything (USB, network signals, keyboard) with the PMSET command is not enough, because there's a higher level of events that affect whether the machine wakes up and also whether it gets prevented from going back to sleep.
  • The potential causes are: partially malfunctioning external hard drives, keyboards, mice, and not just malfunctioning USB hubs. In my case, the actual cause was not identified but by narrowing the circle of potential causes, it is most likely the USB hub. (I need it bad.)
  • There might also be a software reason preventing the device from going to sleep, for example, an application might be sending a "Don't Sleep, I'm working" signal to the operating system. You might not have control over this via some settings, and you can't wait for the external developer. I have such an application, but quitting it didn't help.
  • This also means that the issue partially lies with Apple, as macOS poorly handles the behavior of certain external devices. Furthermore, users are forced to permanently use external hard drives and USB hubs because Macs have too few external ports, and USB-C often needs to be converted to USB-A.
  • Therefore, this implies that the problem is unsolvable on the user-side, but I found a perfect workaround.


The solution is to issue the following command (technically a small program) every night in the Terminal application, which will put the Mac back to sleep on your behalf if it has been awake for more than 5 minutes.


sleep 10; while true; do
    pmset sleepnow
    sleep 300
done


This waits 10 seconds before actually putting the machine to sleep, and then if the Mac is awake again for 5 minutes, it puts the machine back to sleep. You can customize these timings for yourself. Okay, it could be more sophisticated but it does the job.


  • In the morning, you need to interrupt it with ^C, i.e., Ctrl-C. (Focus must be on the Terminal window; red-yellow-green dots in the top-left corner, you know.)
  • The following night, you can easily recall the previous command with the Up arrow key. It's a simple routine.


Mac mini (M4, 2024)

Posted on Dec 15, 2025 2:29 AM

Reply
Question marked as Top-ranking reply

Posted on Jan 11, 2026 1:49 PM

I've created a much more sophisticated script that needs to be placed into a bash script file named sleepmac. Don't forget to make the file executable with the command chmod +x sleepmac. Under CC0 1.0.

This script now checks if the display is active, and only starts the countdown for the Forced Sleep if there is an active display.

Plus, I've made it bilingual because, being Hungarian, I also think of Hungarians (e.g., a friend of mine has the same problem, except he simply turned off the displays at night and didn't care that the Macbook Pro was awake all night). The script detects the system language; if it's not Hungarian, then it communicates in English, so it's full automatic, never mind.


#!/usr/bin/env bash
langs=$(defaults read NSGlobalDomain AppleLanguages | tr -d '",() ')
user_lang="en"

if [[ "$langs" == *hu* ]]; then
	user_lang="hu"
	if [[ -z "$1" ]]; then
		echo "Használat: <min. 10 másodpercnyi kezdeti késleltetés> <min. 20 másodpercnyi ismétlődő időzítés>"
		echo "Pl. sleepmac 10 20 → 10 másodperc múlva elalszik a gép, majd ha aktív kijelzővel felébred (magától, vagy felébreszted), akkor 20 másodperc múlva erőltetve visszaalszik."
		echo ""
		echo "Felébresztés után NE FELEJTSD EL Ctrl-C-vel megszakítani a folyamatot!"
		echo ""
		exit 1
	fi
else
	if [[ -z "$1" ]]; then
		echo "Usage: <minimum 10 seconds initial delay> <minimum 20 seconds recurring timing>"
		echo "E.g. sleepmac 10 20 → The machine will sleep after 10 seconds, then if it wakes up with an active display (automatically, or you wake it), it will forcibly go back to sleep after 20 seconds."
		echo ""
		echo "After waking up your Mac, DON'T FORGET to interrupt this process by hitting Ctrl-C!"
		echo ""
		exit 1
	fi
fi

clear
defaultfirsttiming=10
defaultseqtiming=60
if ! [[ "$1" =~ ^[0-9]+$ ]]; then
	[[ "$user_lang" == "hu" ]] && echo "'$1' nem egész szám → a Mac 10 másodperc múlva elalszik." || echo "'$1' is not an Integer → the Mac enters Sleep Mode in 10 sec."
	echo ""
	firsttiming=$defaultfirsttiming
elif (( $1 < $defaultfirsttiming )); then
	[[ "$user_lang" == "hu" ]] && echo "'$1' az $defaultfirsttiming alatt van → $defaultfirsttiming másodperc múlva alszik el a Mac." || echo "'$1' is below the minimal $defaultfirsttiming value → The Mac will enter Sleep Mode in $defaultfirsttiming sec."
	echo ""
	firsttiming=$defaultfirsttiming
else
	firsttiming=$1
fi
	
if [[ -z "$2" ]]; then
	seqtiming=$defaultseqtiming
	[[ "$user_lang" == "hu" ]] && echo "$seqtiming másodpercenként lesz a visszaaltatás." || echo "The Mac will go back to sleep after $seqtiming sec."
	
elif ! [[ "$2" =~ ^[0-9]+$ ]]; then
	[[ "$user_lang" == "hu" ]] && echo "'$2' nem egész szám → $defaultseqtiming másodpercenként lesz a visszaaltatás." || echo "'$2' is not an Integer → Back-to-Sleep Countdown is $defaultseqtiming sec."
	seqtiming=$defaultseqtiming
elif (( $2 < 20 )); then
	[[ "$user_lang" == "hu" ]] && echo "'$2' az 20 alatt van → 20 másodpercenként lesz a visszaaltatás." || echo "'$2' is below 20 → Back-to-Sleep Countdown is 20 sec."
	seqtiming=20
else
	seqtiming=$2
fi

sleep "$firsttiming"; pmset sleepnow; while true; do
	display_asleep=$(system_profiler SPDisplaysDataType | grep -c "Display Asleep: Yes")

	if [ "$display_asleep" -eq 0 ]; then
		echo ""
		[[ "$user_lang" == "hu" ]] && echo "Kijelző aktív → $seqtiming mp. időzített altatás indul..." || echo "Display active → $seqtiming sec. countdown to Forced Sleep begins..."
		
		for i in $(seq 1 "$seqtiming"); do
			sleep 1
			display_asleep=$(system_profiler SPDisplaysDataType | grep -c "Display Asleep: Yes")
			if [ "$display_asleep" -gt 0 ]; then
				[[ "$user_lang" == "hu" ]] && echo "Kijelző újra elaludt → megszakítás." || echo "Display went back to Sleep → Interruption."
				
				break
			fi
		done

		display_asleep=$(system_profiler SPDisplaysDataType | grep -c "Display Asleep: Yes")
		if [ "$display_asleep" -eq 0 ]; then
			[[ "$user_lang" == "hu" ]] && echo "$seqtiming mp lejárt → altatás." || echo "$seqtiming sec. gone → Sleeping the Mac."
			
			pmset sleepnow
		fi
	fi

	sleep 5
done
11 replies
Question marked as Top-ranking reply

Jan 11, 2026 1:49 PM in response to Vendrel

I've created a much more sophisticated script that needs to be placed into a bash script file named sleepmac. Don't forget to make the file executable with the command chmod +x sleepmac. Under CC0 1.0.

This script now checks if the display is active, and only starts the countdown for the Forced Sleep if there is an active display.

Plus, I've made it bilingual because, being Hungarian, I also think of Hungarians (e.g., a friend of mine has the same problem, except he simply turned off the displays at night and didn't care that the Macbook Pro was awake all night). The script detects the system language; if it's not Hungarian, then it communicates in English, so it's full automatic, never mind.


#!/usr/bin/env bash
langs=$(defaults read NSGlobalDomain AppleLanguages | tr -d '",() ')
user_lang="en"

if [[ "$langs" == *hu* ]]; then
	user_lang="hu"
	if [[ -z "$1" ]]; then
		echo "Használat: <min. 10 másodpercnyi kezdeti késleltetés> <min. 20 másodpercnyi ismétlődő időzítés>"
		echo "Pl. sleepmac 10 20 → 10 másodperc múlva elalszik a gép, majd ha aktív kijelzővel felébred (magától, vagy felébreszted), akkor 20 másodperc múlva erőltetve visszaalszik."
		echo ""
		echo "Felébresztés után NE FELEJTSD EL Ctrl-C-vel megszakítani a folyamatot!"
		echo ""
		exit 1
	fi
else
	if [[ -z "$1" ]]; then
		echo "Usage: <minimum 10 seconds initial delay> <minimum 20 seconds recurring timing>"
		echo "E.g. sleepmac 10 20 → The machine will sleep after 10 seconds, then if it wakes up with an active display (automatically, or you wake it), it will forcibly go back to sleep after 20 seconds."
		echo ""
		echo "After waking up your Mac, DON'T FORGET to interrupt this process by hitting Ctrl-C!"
		echo ""
		exit 1
	fi
fi

clear
defaultfirsttiming=10
defaultseqtiming=60
if ! [[ "$1" =~ ^[0-9]+$ ]]; then
	[[ "$user_lang" == "hu" ]] && echo "'$1' nem egész szám → a Mac 10 másodperc múlva elalszik." || echo "'$1' is not an Integer → the Mac enters Sleep Mode in 10 sec."
	echo ""
	firsttiming=$defaultfirsttiming
elif (( $1 < $defaultfirsttiming )); then
	[[ "$user_lang" == "hu" ]] && echo "'$1' az $defaultfirsttiming alatt van → $defaultfirsttiming másodperc múlva alszik el a Mac." || echo "'$1' is below the minimal $defaultfirsttiming value → The Mac will enter Sleep Mode in $defaultfirsttiming sec."
	echo ""
	firsttiming=$defaultfirsttiming
else
	firsttiming=$1
fi
	
if [[ -z "$2" ]]; then
	seqtiming=$defaultseqtiming
	[[ "$user_lang" == "hu" ]] && echo "$seqtiming másodpercenként lesz a visszaaltatás." || echo "The Mac will go back to sleep after $seqtiming sec."
	
elif ! [[ "$2" =~ ^[0-9]+$ ]]; then
	[[ "$user_lang" == "hu" ]] && echo "'$2' nem egész szám → $defaultseqtiming másodpercenként lesz a visszaaltatás." || echo "'$2' is not an Integer → Back-to-Sleep Countdown is $defaultseqtiming sec."
	seqtiming=$defaultseqtiming
elif (( $2 < 20 )); then
	[[ "$user_lang" == "hu" ]] && echo "'$2' az 20 alatt van → 20 másodpercenként lesz a visszaaltatás." || echo "'$2' is below 20 → Back-to-Sleep Countdown is 20 sec."
	seqtiming=20
else
	seqtiming=$2
fi

sleep "$firsttiming"; pmset sleepnow; while true; do
	display_asleep=$(system_profiler SPDisplaysDataType | grep -c "Display Asleep: Yes")

	if [ "$display_asleep" -eq 0 ]; then
		echo ""
		[[ "$user_lang" == "hu" ]] && echo "Kijelző aktív → $seqtiming mp. időzített altatás indul..." || echo "Display active → $seqtiming sec. countdown to Forced Sleep begins..."
		
		for i in $(seq 1 "$seqtiming"); do
			sleep 1
			display_asleep=$(system_profiler SPDisplaysDataType | grep -c "Display Asleep: Yes")
			if [ "$display_asleep" -gt 0 ]; then
				[[ "$user_lang" == "hu" ]] && echo "Kijelző újra elaludt → megszakítás." || echo "Display went back to Sleep → Interruption."
				
				break
			fi
		done

		display_asleep=$(system_profiler SPDisplaysDataType | grep -c "Display Asleep: Yes")
		if [ "$display_asleep" -eq 0 ]; then
			[[ "$user_lang" == "hu" ]] && echo "$seqtiming mp lejárt → altatás." || echo "$seqtiming sec. gone → Sleeping the Mac."
			
			pmset sleepnow
		fi
	fi

	sleep 5
done

Jan 11, 2026 3:35 PM in response to Vendrel

Minor refinement. Sorry. I noticed too late, it's no longer editable.


#!/usr/bin/env bash
langs=$(defaults read NSGlobalDomain AppleLanguages | tr -d '",() ')
user_lang="en"

if [[ "$langs" == *hu* ]]; then
	user_lang="hu"
	if [[ -z "$1" ]]; then
		echo "Használat: <min. 10 másodpercnyi kezdeti késleltetés> <min. 20 másodpercnyi ismétlődő időzítés>"
		echo "Pl. sleepmac 10 20 → 10 másodperc múlva elalszik a gép, majd ha aktív kijelzővel felébred (magától, vagy felébreszted), akkor 20 másodperc múlva erőltetve visszaalszik."
		echo ""
		echo "Felébresztés után NE FELEJTSD EL Ctrl-C-vel megszakítani a folyamatot!"
		echo ""
		exit 1
	fi
else
	if [[ -z "$1" ]]; then
		echo "Usage: <minimum 10 seconds initial delay> <minimum 20 seconds recurring timing>"
		echo "E.g. sleepmac 10 20 → The machine will sleep after 10 seconds, then if it wakes up with an active display (automatically, or you wake it), it will forcibly go back to sleep after 20 seconds."
		echo ""
		echo "After waking up your Mac, DON'T FORGET to interrupt this process by hitting Ctrl-C!"
		echo ""
		exit 1
	fi
fi

clear
defaultfirsttiming=10
defaultseqtiming=60
if ! [[ "$1" =~ ^[0-9]+$ ]]; then
	[[ "$user_lang" == "hu" ]] && echo "'$1' nem egész szám → a Mac 10 másodperc múlva elalszik." || echo "'$1' is not an Integer → the Mac enters Sleep Mode in 10 sec."
	echo ""
	firsttiming=$defaultfirsttiming
elif (( $1 < $defaultfirsttiming )); then
	[[ "$user_lang" == "hu" ]] && echo "'$1' az $defaultfirsttiming alatt van → $defaultfirsttiming másodperc múlva alszik el a Mac." || echo "'$1' is below the minimal $defaultfirsttiming value → The Mac will enter Sleep Mode in $defaultfirsttiming sec."
	echo ""
	firsttiming=$defaultfirsttiming
else
	firsttiming=$1
fi
	
if [[ -z "$2" ]]; then
	seqtiming=$defaultseqtiming
	[[ "$user_lang" == "hu" ]] && echo "$firsttiming másodperc múlva elalszik a gép." || echo "The Mac will enter Sleep Mode in $firsttiming sec."
	[[ "$user_lang" == "hu" ]] && echo "$seqtiming másodpercenként lesz a visszaaltatás." || echo "The Mac will go back to sleep after $seqtiming sec."
	
elif ! [[ "$2" =~ ^[0-9]+$ ]]; then
	[[ "$user_lang" == "hu" ]] && echo "$firsttiming másodperc múlva elalszik a gép." || echo "The Mac will enter Sleep Mode in $firsttiming sec."
	[[ "$user_lang" == "hu" ]] && echo "'$2' nem egész szám → $defaultseqtiming másodpercenként lesz a visszaaltatás." || echo "'$2' is not an Integer → Back-to-Sleep Countdown is $defaultseqtiming sec."
	seqtiming=$defaultseqtiming
elif (( $2 < 20 )); then
	[[ "$user_lang" == "hu" ]] && echo "$firsttiming másodperc múlva elalszik a gép." || echo "The Mac will enter Sleep Mode in $firsttiming sec."
	[[ "$user_lang" == "hu" ]] && echo "'$2' az 20 alatt van → 20 másodpercenként lesz a visszaaltatás." || echo "'$2' is below 20 → Back-to-Sleep Countdown is 20 sec."
	seqtiming=20
else
	seqtiming=$2
fi

sleep "$firsttiming"; pmset sleepnow; while true; do
	display_asleep=$(system_profiler SPDisplaysDataType | grep -c "Display Asleep: Yes")

	if [ "$display_asleep" -eq 0 ]; then
		echo ""
		[[ "$user_lang" == "hu" ]] && echo "Kijelző aktív → $seqtiming mp. időzített altatás indul..." || echo "Display active → $seqtiming sec. countdown to Forced Sleep begins..."
		
		for i in $(seq 1 "$seqtiming"); do
			sleep 1
			display_asleep=$(system_profiler SPDisplaysDataType | grep -c "Display Asleep: Yes")
			if [ "$display_asleep" -gt 0 ]; then
				[[ "$user_lang" == "hu" ]] && echo "Kijelző újra elaludt → megszakítás." || echo "Display went back to Sleep → Interruption."
				
				break
			fi
		done

		display_asleep=$(system_profiler SPDisplaysDataType | grep -c "Display Asleep: Yes")
		if [ "$display_asleep" -eq 0 ]; then
			[[ "$user_lang" == "hu" ]] && echo "$seqtiming mp lejárt → altatás." || echo "$seqtiming sec. gone → Sleeping the Mac."
			
			pmset sleepnow
		fi
	fi

	sleep 5
done

Dec 16, 2025 1:28 AM in response to Old Toad

This is just your personal solution for your personal use case, but others constitute different use cases, en masse.


Shutting down may disrupt your work layout on three displays.


For example, you're developing software, editing video, working in Photoshop, etc. etc. etc., and you want to continue exactly where you left off, not where the system decides to place things when you turn the machine back on.


Or: you just have a bunch of web pages open (still interested but the night came), especially if you don't have 128 GB of RAM in your machine (and extra RAM is very expensive at Apple). In that case, you're putting the web pages to sleep (if you're smart, saving your SSD, which is easy to overuse with virtual memory, eventually bricking your Mac, forcing the machine into it if you don't put the web pages to sleep), and this also starts to malfunction if you turn the machine off and on, because all the websites get reloaded all at once again. Some (like you) may not encounter this as much, but others (other people out there in the big wide world) want to avoid it.

Dec 16, 2025 1:40 AM in response to den.thed

Again, this fits your personal use case, but there are people out there constituting different use cases.


In your Mac, there's an internal SSD you can't replace, and if you're not rolling in money (and most people aren't), you didn't splurge on the super expensive internal storage or RAM when you ordered your Mac. Instead, you/we probably bought something close to the base model configuration and expanded it with an external SSD.


Now, SSDs wear out depending on how much you use them (it can be measured, there's a tool for that), and by not putting your computer to sleep and just letting it run in the background all night, you're adding SSD usage on top of your normal usage, which speeds up its wear and tear.


The situation with the external SSD is both better and worse because its cooling is worse. External SSDs get very hot, and their cooling isn't great (mine is manual, so it's not hot anymore, but mac Mac is in the bedroom, so it must be disabled at night – winking back to the different use cases thing).


If your Mac is running all night, you're essentially baking your external SSD as well. Remember this when it completely fries.


Anyways, this entire post and the solution aren't for those who don't have this problem (yet, just wait), but for those who do.

Dec 19, 2025 12:05 PM in response to Old Toad

I don't want to shut it down, I want to resolve the problem and eventually see the problem disappear.


By design, this and every Mac is capable of sleeping every night or any time users want, AND its fundamental benefit of this is that I don't have to interrupt this sleep sequence with anything other than installing the next system update.

This is what I paid for, so this is what I want to get, with all its benefits I enjoy and build my use case based on.


THE SOLUTION ISN'T TO USE IT LIKE A PC. THIS IS A MACINTOSH, NOT A PC.

Dec 19, 2025 12:34 PM in response to Vendrel

We are just Apple users like yourself and there is nothing that we can do but offer suggestions.


If you have feedback for Apple, you should contact Apple Support and/or use their Feedback links.

Official Apple Support

Feedback - Mac mini - Apple

Feedback - macOS - Apple


FWIW in addition to new Mac mini's, we have a 2018 Mac mini that has been running 24-7 for over 7 years and it still reports a healthy internal SSD.

Dec 19, 2025 12:46 PM in response to den.thed

Thanks for the links. :) Yeah, that happens elsewhere. On this forum, I provide insights and a workaround to those who face the same issues.

Tonight, I'm going to test a more sophisticated script that only puts the computer back to sleep if the display also woke up during the normal automatic wake-up process. If the display wakes up, the computer won't go back to sleep on its own. If it goes back to sleep on its own, it won't wake up the display.

Mac not returning to Sleep Mode: Causes and Workaround

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.