Describe the Bug
My initializeCommand executes docker compose down and then generates a .env file for the dev container before Cursor starts the dev container. We do this to ensure any existing containers that were started outside of Cursor are recreated with the correct Dev Containers specific .env file.
Every time my computer wakes from sleep (every morning, after lunch or any other sufficiently long break), Cursor executes the initializeCommand which triggers a reconnect attempt (obviously, because the dev container was downed).
This reconnect attempt always fails and I am then left with “Cannot reconnect. Please reload the window.” in a popup error. Perhaps the reconnect timeout is too short? Or perhaps the container ID has changed?
My containers are still running. I can still see logging output in Cursor from my postAttachCommand, which is docker compose logs -f ...
I can still access service containers and exec into the dev container from Terminal app, but I cannot open a new terminal from Cursor. I have to reload the window.
On reloading the window the bottom left corner says “Opening Remote” as opposed to “Reconnecting to Container”. Perhaps reconnecting has a shorter timeout than opening? Or tries to reconnect to an existing known container ID instead of creating a new container to connect to?
I tested by changing my initializeCommand to just echo RUNNING INITIALIZE COMMAND to confirm that this is in fact executing on wake from sleep and that this is causing the reconnect attempt.
Reloading the window is disruptive because it erases my undo history for any work that was in progress.
From a working dev container, if I click on the bottom left corner and select Trigger reconnect (or Dev Containers: Trigger Reconnect from CMD-P command palette, I get exactly the same behaviour where initializeCommand is executed, which downs my dev container and then cannot reconnect.
There are two things that could (and should) be done to improve this.
- Do not execute
initializeCommandon wake or on reconnect.
My IntelliSense for that option says “A command to run locally (i.e Your host machine, cloud VM) before anything else. This command is run before “onCreateCommand”. If this is a single string, it will be run in a shell. If this is an array of strings, it will be run as a single command without shell. If this is an object, each provided command will be run in parallel.”
Merely reconnecting (e.g. after sleep) does not sound like it should go through the entire setup again. We are not “creating” (or recreating) the dev container. Just reconnecting to the dev container that is already there.
- Increase the reconnect timeout or otherwise try to reconnect to the correct container ID.
This would at least avoid being stuck on “Cannot reconnect. Please reload the window.” which erases my undo history.
Steps to Reproduce
Add "initializeCommand": "echo RUNNING INITIALIZE COMMAND" to your devcontainer.json file and observe that it appears in your Terminal tab on wake from sleep and on Trigger Reconnect.
Add "initializeCommand": "docker compose down" to your devcontainer.jsonfile and observe thatTrigger Reconnect` is unable to reconnect.
Expected Behavior
Dev Container remains connected or at least is able to reconnect successfully on wake from sleep. initializeCommand is not executed on reconnect.
Screenshots / Screen Recordings
Operating System
MacOS
Current Cursor Version (Menu → About Cursor → Copy)
Version: 1.3.4
VSCode Version: 1.99.3
Commit: bfb7c44bcb74430be0a6dd5edf885489879f2a20
Date: 2025-07-29T03:47:28.903Z
Electron: 34.5.1
Chromium: 132.0.6834.210
Node.js: 20.19.0
V8: 13.2.152.41-electron.0
OS: Darwin arm64 24.5.0
Does this stop you from using Cursor
No - Cursor works, but with this issue

