20

I have a Mac which I connect to using Screen Sharing to log in and start a video playing. Since upgrading to El Capitan, when I quit the screen sharing client, the screen on the remote machine turns off. How do I stop this from happening, while still having the screen turn off normally after a few minutes of inactivity?

6 Answers 6

37

Run this command in the terminal to fix the external screen going blank on VNC disconnect. Works with Sierra OS.

sudo defaults write /Library/Preferences/com.apple.RemoteManagement RestoreMachineState -bool NO 

More context from jabenninghoff on GitHub:

In newer versions of macOS, screen sharing will automatically re-lock the screen when you disconnect if it was locked when you first connected.

5
  • tested and works on el cap (v 10.11.6) Commented Sep 13, 2017 at 18:20
  • 1
    Also works on High Sierra (tested on 10.13.1). Thanks. Commented Dec 8, 2017 at 13:04
  • 1
    Still works on High Sierra as of July 2018. Thank you! Perfect for headless or home theater Mac. Commented Jul 24, 2018 at 0:32
  • OMG THANK YOU! This was driving me nuts and I couldn't figure it out. Here we are years later and presto! Commented Mar 13, 2020 at 13:44
  • Confirmed still works on Monterey 12.5.1 Commented Aug 30, 2022 at 7:50
5

Under System Preferences > Sharing, use “Remote Management” instead of “Screen Sharing”, as shown here:

Screenshot of Sharing Preference Pane

As far as I can tell, everything else works the same but the screen no longer turns off when you disconnect a Screen Sharing connection.

edited to add: this is under 10.11.3

2
  • Sadly, even that does not seem a 100% solution. I wish there was a better way. sigh Commented May 7, 2016 at 1:25
  • 1
    Yeah, it appeared to work, but turns out it only works sometimes. Can't figure out what the pattern is for when it works and when it doesn't. Commented May 9, 2016 at 22:23
3

To be clear - the top-rated solution here alone from colo2100cent does not solve the problem if you're connecting to a MacBook with the lid closed (tested using a mid 2011 MacBook Air running Sierra - VNC disconnect required opening the lid and a physical button press to wake it up), but works fine if you're using a desktop based Mac like a Mac mini or an iMac. A display must be connected externally for this to work on a MacBook, but this is wasteful if it's being stored in a closet as a server or otherwise not being physically accessed.

What solved the problem for me was executing the command in colo2100cent's answer:

sudo defaults write /Library/Preferences/com.apple.RemoteManagement RestoreMachineState -bool NO 

while also having a headless ghost display connected to the miniDP port, purchased for about 10 bucks. It tricks your MacBook into thinking there's a monitor connected at all times but does not require a monitor. Works like a charm - no more sleeping after VNC disconnect.

3
  • 1
    Like @fitzroy pointed out in the other answer, this only works if the display (either real or fake) is plugged in during boot. Commented Jul 1, 2021 at 22:06
  • 2
    Also for anyone who is curious, I used Amphetamine to keep the Macbook from sleep. Otherwise it won't respond to VNC in the first place once lid is closed. Amphetamine could not deal with the VNC disconnection sleep though. Commented Jul 1, 2021 at 22:07
  • This worked when I needed to unlock a machine remotely running Monterey and didn't want to re-lock after I closed the connection. Commented May 8, 2023 at 23:27
0

I also have this issue (2012 Mac running El Capitan 10.11.5). I did not have this issue on my 2007 Mac Mini running 10.6.8 with a similar configuration (except using DVI instead of HDMI). When I close Mac screensharing or TouchPad on iOS, or switch iOS apps or lock the phone, the Mac Mini turns off external video.

The workaround I've found is: Hit pause / play on the Apple Remote (the physical infrared remote — not an app) after starting the video, before closing screensharing. Then you should be able to close screensharing and the screen will stay on. I've also done this with the Apple bluetooth mouse and it works as well.

You can also accomplish this by waking the Mac Mini with the remote before initiating screensharing, if you remember. Annoying though since it will often open and start playing iTunes.

The Mac just seems to need some input from a physical device (mouse or remote) after waking to prevent it putting the screen back to sleep.

Going to try the Remote Management checkbox also to see if that helps.

0

I solved this by restarting the Mac with the display (the TV) already ON.

If starting the Mac with the display off, either using Remote Management or Screen Sharing will result in the display turning off after disconnecting the VNC client.

0

I know this is a four year old question, but I think I may have finally found a foolproof solution.

The issue is that if it can't detect a display in any capacity it will put it to sleep, the commands don't work anymore(?), etc. Well here is how you create a display without any costly dongles. BetterDisplay, allows you to create virtual displays for free, and at pretty much any resolution. Once the virtual display has been created the Mac will always think it is on and disconnecting from a VNC session will not put the computer to sleep.

Now I am certain I have entered colo2100cent's command into my terminal, I am not sure if it also is required. But so far BetterDisplay has solved the issue.

I am using an old MacBook Pro that has a disconnected damaged display with the lid closed.

1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center. Commented Dec 6, 2024 at 9:36

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.