Why do my Mac's windows move when I connect or disconnect a monitor?

Updated 1 October 2026 · 3 min read · by

Quick answer

When a display disappears, macOS has to move its windows onto a screen that still exists, so they pile up on your laptop. When the display comes back, macOS tries to put them back, but it only manages it when it recognizes the display as the same one, nothing else moved in between, and the app cooperates. Docks, adapters, sleep and identical monitors break that often. You can reduce it with a few settings, or use an app like Anchor that remembers each setup and restores it.

What macOS does when a display disconnects

A window can't live on a screen that no longer exists. The moment you unplug a monitor, close a dock connection, or the display goes to sleep in a way the Mac reads as "disconnected", macOS moves every window from that display onto the remaining ones, usually your laptop's built-in screen. Windows that were bigger than the laptop screen are shrunk to fit. That part is unavoidable and is the same on every Mac.

Why they don't always go back

When the monitor returns, macOS tries to move windows back to where they were. In practice that often fails, and you'll usually see one of these patterns:

How to reduce the shuffling with built-in settings

  1. Plug into the same port every time. Use the same cable, dock and Mac port for each monitor so macOS sees the same display arrangement each time.
  2. Check your arrangement once. Open Apple menu › System Settings › Displays and click Arrange. Drag the displays to match where they sit on your desk, and drag the menu bar to the display you want as the main one.
  3. Pick your main display. In Displays, click the monitor's name and set Use as to Main display. The main display holds the menu bar and is where new windows tend to open.
  4. Assign apps to a display. If you use Spaces, Control-click an app's icon in the Dock, choose Options, and under Assign To pick Desktop on Display and a number. That app then opens on that display.
  5. Keep "Displays have separate Spaces" consistent. It's in System Settings › Desktop & Dock, under Mission Control. Turning it on or off changes how windows and Spaces behave on each display, so pick one and leave it.
  6. Update macOS and your dock's firmware. Display handling improves between macOS versions, and many docks get firmware updates that fix disconnects on sleep.

What helps, at a glance

SituationWhy windows moveWhat to try
Different dock or port each dayThe monitor looks like a new displayUse the same dock and port, or a tool that recognizes monitors by hardware ID
Two identical monitorsThe Mac can't tell them apart reliablyKeep each cable in the same port; check Arrange after reconnecting
Windows piled up after sleepThe monitor or dock dropped off while asleepUpdate dock firmware; try a different cable or port
Some apps always open on the laptopThey open where the main display or pointer isSet the main display; assign the app in Dock › Options › Assign To

Can macOS remember a layout per monitor setup?

Not as a feature you control. macOS has no "save this window layout" setting, and its window tiling (in macOS Sequoia and later) arranges windows on one screen but doesn't remember where they go for each combination of monitors. That's the gap layout apps fill: they save a layout per setup and put windows back when that setup reappears.

Questions people ask

Why does my Mac move all my windows to the laptop screen?

Because the display they were on disconnected, even briefly. macOS has to put windows on a screen that exists, so it gathers them onto the remaining display. A dock or monitor that drops out during sleep causes the same thing.

Why don't my windows go back when I reconnect the monitor?

macOS only restores them when it recognizes the monitor as the same display and nothing has changed in between. A different port or dock, identical monitors, or rearranging windows while the monitor was away all stop it from restoring.

Is there a setting to make macOS remember window positions?

No. macOS doesn't have a setting to save window layouts per monitor setup. You can reduce the problem by using the same ports, setting a main display and assigning apps to displays, or use an app that saves and restores layouts.

Does this happen on every Mac?

Yes. It happens on any Mac that connects and disconnects external displays, from MacBook Air to Mac Studio, because the behavior comes from how macOS handles displays appearing and disappearing.