PSA: If your 2015 or 2016 MBP has some battery drain while sleeping, here is the fix

Mixolyd

macrumors member
Original poster
Jul 10, 2014
74
32
Oregon
Update: I no longer recommend using this fix. Something changed in 10.12.4. After redoing the steps outlined, I saw that the drain was about the same as without the fix, but then for the next days saw that it actually was worse. One night my battery dropped 10% overnight, and pmset showed no wakes. Very odd. I had to revert to a Time Machine backup because simply undoing the steps by changing the text does not revert this for whatever reason. So my suggestion is that if you are on 10.12.4 then do not follow this guide and learn to live with the slight drain that occurs. I'm not aware of any fix at the moment. Note this is with a 2016 MBP nTB so it may be different with 2015 or the regular MB.
 

MrGuder

macrumors 68030
Nov 30, 2012
2,878
1,871
Update: I no longer recommend using this fix. Something changed in 10.12.4. After redoing the steps outlined, I saw that the drain was about the same as without the fix, but then for the next days saw that it actually was worse. One night my battery dropped 10% overnight, and pmset showed no wakes. Very odd. I had to revert to a Time Machine backup because simply undoing the steps by changing the text does not revert this for whatever reason. So my suggestion is that if you are on 10.12.4 then do not follow this guide and learn to live with the slight drain that occurs. I'm not aware of any fix at the moment. Note this is with a 2016 MBP nTB so it may be different with 2015 or the regular MB.
I'm running 10.12.4 and I am still using this fix and it still works for me. I'm getting about 3 or 4% drain overnight but I'm fine with that, it's nowhere near the 10% your getting. I wonder why it's working for me. I have a 2016 15" 2.7/512/455. I even went back into setting after I upgraded to 10.12.4 and the setting did not change any of my prior setting for this fix. I know some mentioned that it changed it but not for me.
 

Mixolyd

macrumors member
Original poster
Jul 10, 2014
74
32
Oregon
I'm running 10.12.4 and I am still using this fix and it still works for me. I'm getting about 3 or 4% drain overnight but I'm fine with that, it's nowhere near the 10% your getting. I wonder why it's working for me. I have a 2016 15" 2.7/512/455. I even went back into setting after I upgraded to 10.12.4 and the setting did not change any of my prior setting for this fix. I know some mentioned that it changed it but not for me.
The 10% was just one night and the next night was maybe 6%. Overall for about a week I was getting about ~4% drain. I ran "ioreg -l | grep IOPlatformFeatureDefaults" after 10.12.4 update and everything reverted to default. Not sure why it didn't for you.

Isn't it odd that the battery would drain 4% overnight even when pmset says that it was in deep sleep the whole time? Very weird. My old 2014 has no drain at all. They must have changed something about how the battery works.
 

MrGuder

macrumors 68030
Nov 30, 2012
2,878
1,871
Oh ok, I really don't have anything to compare it against as this is my first Macbook Pro laptop. I didn't revert the setting back to see if the 3 or 4 % was the same without the fix. I just figured the 3 or 4% drain was normal.
 

Sanpete

macrumors 68030
Nov 17, 2016
2,596
1,055
Utah
Isn't it odd that the battery would drain 4% overnight even when pmset says that it was in deep sleep the whole time?
Yes, that seems odd, but not as much as 10%! Should keep the RAM powered up for three hours, and then enter standby and use very little power after that.
 

MrGuder

macrumors 68030
Nov 30, 2012
2,878
1,871
As I mentioned I'm still using the fix and last night I made sure to look at what I had and battery showed 81% so this morning (9.5 hrs later) I looked to see what it showed overnight and it says 79% so I only lost 2% overnight. I never shut down my laptop, just close the lid every time I'm done.
 

MrGuder

macrumors 68030
Nov 30, 2012
2,878
1,871
Edited, sorry wrong thread, wrong fix, thought this was the notification fix which is what I recommend.
 

JohnnyW2001

Suspended
Nov 6, 2012
159
43
Unfortunately DND didn't make any difference and, astonishingly, after leaving my MBP in sleep mode for a day the battery went from 70% to 0%! :-/

Maybe forced hibernation is the best solution. Hmm. Really we should be able to stop it reaching out for notifications while asleep!

@Mixolyd Have you made any further headway with your investigations?
 

Aikikaio

macrumors newbie
Jul 16, 2017
3
3
Backstory: I just got a 2016 13'' non TB MBP. I noticed that after sleeping for a day or two, there was some battery drain. I also have a 2014 rMBP which does not drain at all. I tested and it seemed to drain 5% over 24 hours while the 2014 did not. After pulling my hair out trying to find a fix, I finally found one. Credit goes to Seny on the official Apple forums who figured it out. Link The issue seems to be that 2015 and 2016 MBPs are set to wake up during sleep for notifications. If I ran "log show --style syslog | fgrep "Wake reason" I'd have wakes every 10-20 minutes.

To see if you are affected, run "ioreg -l | grep IOPlatformFeatureDefaults" -- On my 2014 model TCPKeepAliveDuringSleep was set to No, but on my 2016 it was set to Yes.

In order to change this, first you have to turn off SIP. Boot into recovery mode (CMR+R) then "csrutil disable" (don't forget to enable again later). Then in Finder menu Go to folder "/System/Library/Extensions/IOPlatformPluginFamily.kext/Contents/PlugIns/X86PlatformPlugin.kext/Contents/Resources" Depending on which MBP you have, the file you have to edit is different. Run " ioreg -l | grep board-id" in terminal to figure out the correct file. Then right click on the file, get info, change permission for Everyone to read & write. Open with texteditor (I used Textwrangler) and look for these 4 entries and just completely delete them

> <key>TCPKeepAliveDuringSleep</key>
> <true/>
> <key>TCPKeepAliveExpirationTimeout</key>
> <integer>43200</integer>
> <key>NotificationWake</key>
> <true/>
> <key>DNDWhileDisplaySleeps</key>
<false/>


Save and reboot. Worked for me. Now I have very few wakes when sleeping and battery drain is much better. I'm reporting the bug to Apple. Please do the same so they fix it. Whatever changes you make will probably be overwritten by any updates so they'll need to fix it permanently


Update: I no longer recommend using this fix. Something changed in 10.12.4. After redoing the steps outlined, I saw that the drain was about the same as without the fix, but then for the next days saw that it actually was worse. One night my battery dropped 10% overnight, and pmset showed no wakes. Very odd. I had to revert to a Time Machine backup because simply undoing the steps by changing the text does not revert this for whatever reason. So my suggestion is that if you are on 10.12.4 then do not follow this guide and learn to live with the slight drain that occurs. I'm not aware of any fix at the moment. Note this is with a 2016 MBP nTB so it may be different with 2015 or the regular MB.

I solved the problem on my MacBook Pro 2016 by turning off the TCPKeepAliveDuringSleep option with the command:
sudo pmset -b TCPKeepAliveDuringSleep 0

Of course if you want to go back at any time you can open terminal and enter:sudo pmset -b TCPKeepAliveDuringSleep 1

Enjoy
 

0dev

macrumors 68040
Dec 22, 2009
3,947
23
127.0.0.1
I solved the problem on my MacBook Pro 2016 by turning off the TCPKeepAliveDuringSleep option with the command:
sudo pmset -b TCPKeepAliveDuringSleep 0

Of course if you want to go back at any time you can open terminal and enter:sudo pmset -b TCPKeepAliveDuringSleep 1

Enjoy
This command does not work, the correct command is:

sudo pmset -a tcpkeepalive 0

After you enter your password for sudo it gives you a warning saying some features may not work properly but it disables internet during sleep.

You can check it works by running:

pmset -g

Which should show "tcpkeepalive 0"

And you can of course reverse it at any time by running:

sudo pmset -a tcpkeepalive 1

Easy!

Personally I like keeping this off as it saves power and my laptop has absolutely no reason to connect to the internet during sleep.
 

Aikikaio

macrumors newbie
Jul 16, 2017
3
3
This command does not work, the correct command is:

sudo pmset -a tcpkeepalive 0

After you enter your password for sudo it gives you a warning saying some features may not work properly but it disables internet during sleep.

You can check it works by running:

pmset -g

Which should show "tcpkeepalive 0"

And you can of course reverse it at any time by running:

sudo pmset -a tcpkeepalive 1

Easy!

Personally I like keeping this off as it saves power and my laptop has absolutely no reason to connect to the internet during sleep.

Rather than say that this command does not work It's better to explain the difference between the two.
sudo pmset -a tcpkeepalive 0, change the behavior of your mac when It's connected to power suply or not.
sudo pmset -b tcpkeepalive 0, change the behavior of your mac just when It's running from battery.

Because I don't care about bettery drain when my mac It's plug to power suply ;-), I prefere to use this last command.

If you have any doubt you can google It or type just pmset help on your mac.
 
  • Like
Reactions: JohnnyW2001

sirgib

macrumors 6502a
Jun 18, 2012
676
741
I solved the problem on my MacBook Pro 2016 by turning off the TCPKeepAliveDuringSleep option with the command:
sudo pmset -b TCPKeepAliveDuringSleep 0

Of course if you want to go back at any time you can open terminal and enter:sudo pmset -b TCPKeepAliveDuringSleep 1

Enjoy
Doesnt work.

Pauls-MacBook-Pro:~ paul$ sudo pmset -b TCPKeepAliveDuringSleep 0

Usage: pmset <options>

See pmset(1) for details: 'man pmset'

Pauls-MacBook-Pro:~ paul$​
 
  • Like
Reactions: navier

t2nerb

macrumors newbie
Feb 22, 2008
24
9
Doesnt work.

Pauls-MacBook-Pro:~ paul$ sudo pmset -b TCPKeepAliveDuringSleep 0

Usage: pmset <options>

See pmset(1) for details: 'man pmset'

Pauls-MacBook-Pro:~ paul$​
That isn't the correct command. Instead, use: 'pmset -b tcpkeepalive 0'

This will set tcpkeepalive to 0 for battery mode. Replace '-b' with '-c' to set tcpkeepalive for charging mode. I personally leave it on in charging mode, and only set it for battery.

To see a list of the configurable power settings, use: 'pmset -g'. I recommend reading the man page for more information.
 
  • Like
Reactions: SNUKE and navier

JohnnyW2001

Suspended
Nov 6, 2012
159
43
I solved the problem on my MacBook Pro 2016 by turning off the TCPKeepAliveDuringSleep option with the command:
sudo pmset -b TCPKeepAliveDuringSleep 0

Of course if you want to go back at any time you can open terminal and enter:sudo pmset -b TCPKeepAliveDuringSleep 1

Enjoy
Are you sure that wasn't a typo? In a later post you say it's TCPKeepAlive not TCPKeepAliveDuringSleep

Also if you use the -b switch then pmset -g shows 1 (not 0). Any idea why this is?
 
Last edited:

t2nerb

macrumors newbie
Feb 22, 2008
24
9
Are you sure that wasn't a typo? In a later post you say it's TCPKeepAlive not TCPKeepAliveDuringSleep

Also if you use the -b switch then pmset -g shows 1 (not 0). Any idea why this is?
It's because you set it for battery mode. If you unplug your computer and run 'pmset -g' it should show 0 if you executed the command correctly.
 
  • Like
Reactions: JohnnyW2001

JohnnyW2001

Suspended
Nov 6, 2012
159
43
Thanks, you're exactly right. Furthermore...... IT WORKS! No more battery drain when it's asleep! Woo!
 
  • Like
Reactions: adib

SNUKE

macrumors newbie
Sep 17, 2012
9
3
That isn't the correct command. Instead, use: 'pmset -b tcpkeepalive 0'
Thanks this worked a treat.
I was shocked coming form a 2012 (Battery replacement program) to a 2016 and seeing battery drop insane amount overnight. 16hrs since I closed the laptop and not 1% power drop, just like the 2012 was.
 
Last edited:
  • Like
Reactions: adib

SNUKE

macrumors newbie
Sep 17, 2012
9
3
Seems I spoke too soon.

I had the laptop charging overnight, unplugged it before work, opened up 13hrs later, and it wouldn't turn on. Plugged in power cable and it eventually did with 3% battery life showing.

2016 15" MBPr, 2 days ago in Terminal I ran 'pmset -b tcpkeepalive 0' and then 'pmset -g' which showed 'tcpkeepalive = 0'

First night all good, battery kept 100% over 16hrs, hence my earlier reply. Then next time, it lost everything within 13hrs.

I just ran 'pmset -g' again and this is the full result:



And then this:

ioreg -l | grep IOPlatformFeatureDefaults

"IOPlatformFeatureDefaults" = {"TCPKeepAliveDuringSleep"=Yes,"DNDWhileDisplaySleeps"=No,"TCPKeepAliveExpirationTimeout"=43200,"NotificationWake"=Yes}

What does the above mean, why did it work the first night, then fail the next?
 

SNUKE

macrumors newbie
Sep 17, 2012
9
3
Another day, 18hrs in sleep mode, battery stayed at 100%, so no idea why the above happened. Hope it stays this way.
 

t2nerb

macrumors newbie
Feb 22, 2008
24
9
Another day, 18hrs in sleep mode, battery stayed at 100%, so no idea why the above happened. Hope it stays this way.
You can try using: 'pmset -g log | egrep Wake' to see what's causing your computer to wake up.
 

Barry83

macrumors newbie
Sep 7, 2017
18
7
Germany
That isn't the correct command. Instead, use: 'pmset -b tcpkeepalive 0'

This will set tcpkeepalive to 0 for battery mode. Replace '-b' with '-c' to set tcpkeepalive for charging mode. I personally leave it on in charging mode, and only set it for battery.

To see a list of the configurable power settings, use: 'pmset -g'. I recommend reading the man page for more information.
my terminal shows this message
Warning: This option disables TCP Keep Alive mechanism when sytem is sleeping. This will result in some critical features like 'Find My Mac' not to function properly.

'pmset' must be run as root...

any idea?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.