MicroPython board runs main.py at boot and Thonny cannot connect: how to stop it

Press the Stop button or Ctrl+C in the shell to interrupt main.py. If it blocks at once, remove or rename main.py.

What the message means

The board runs main.py as soon as it powers up. A script that loops forever or uses the serial port can stop the editor from getting a prompt.

Fix it in this order

  1. Press the Stop button in Thonny, or Ctrl+C, several times to get the prompt.
  2. Add a short delay at the top of main.py so you have a window to interrupt.
  3. If you cannot interrupt it, reset the board and press Stop straight away.
  4. As a last choice erase or reflash the firmware, then copy your files back.
  5. Keep a small test file separate from main.py while you develop.
  6. Do not make main.py use the same serial port that the editor needs.

If you see this, do this

You seeDo this
No prompt appearsInterrupt during the first seconds after reset.
Cannot interrupt at allReflash the firmware.

Thonny cannot connect, ESP32 boot mode.

Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.