macOS High Sierra restarting by itself during sleep

I have a 2017 MacBook Pro 15″ with High Sierra. I never turn off my laptop, instead I simply put it to sleep, so next day it's easier and faster to turn it on.

But often when I wake it up the next day, it has rebooted by itself. How can I see the shutdown/reboot cause, to try to fix it?

Here is the result of command "pmset -g"

System-wide power settings:
Currently in use:
 standbydelay         10800
 standby              1
 womp                 0
 halfdim              1
 hibernatefile        /var/vm/sleepimage
 powernap             0
 gpuswitch            2
 networkoversleep     0
 disksleep            0
 sleep                15 (sleep prevented by nsurlsessiond, nsurlsessiond, sharingd, coreaudiod)
 autopoweroffdelay    28800
 hibernatemode        3
 autopoweroff         0
 ttyskeepawake        1
 displaysleep         15
 tcpkeepalive         1
 acwake               0
 lidwake              1

Solution 1:

You can find the last shutdown cause by examining the logs. Run this command to filter the logs for shutdown causes:

log show --predicate 'eventMessage contains "Previous shutdown cause"' --last 24h

You can then lookup the shutdown cause code in this table: macOS Shutdown Causes.

Solution 2:

Not exactly the same, but I had a similar issue – after some time I always found my Mac trying to close all my applications (to restart or log out, I don't know. Thanks to iTerms, which stopped this evil Mac and prevented log out every time).

It was 'Log out after X minutes of inactivity' checkbox, accidentally found in

System Preferences > Security & Privacy > Advanced (in right-bottom corner)

Anyone having the same issue as I had, try checking it off.enter image description here

Solution 3:

This is what worked for me

Opening the terminal and running this:

pmset -g

gave me an output of:

Currently in use:
autopoweroffdelay 21600
autopoweroff 1
... a bunch of other stuff

autopoweroff caused my computer to turn off after 6 hours (21600 sec).

running this turn off autopoweroff:

sudo pmset -a autopoweroff 0

Solution 4:

Does this work for you? https://discussions.apple.com/message/32878814#message32878814

  1. Shut down
  2. Disconnect all external devices
  3. Reset the System Management Controller (SMC), repeat 2/3 times
  4. Reset the nonvolatile random-access memory (NVRAM), repeat 2/3 times
  5. Then use safeboot (SHIFT at Startup)
  6. Then reboot normally with devices disconnected.

Solution 5:

It looks like a bug to me. My system is restarting (according to what I can make out from the logs) due to a 'watchdog' timeout. Basically, this means that something has failed to release a resource within a defined period of time which has caused the system to 'hang' and a restart is performed to resolve the condition.