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

> Fix a MicroPython board that you cannot interrupt: press Ctrl+C in the shell, use the Stop button, or remove or rename main.py from the board.

Canonical: https://roboticsengineering.in/fix/micropython-main-py-runs-at-boot-cannot-connect/ | Published: 2026-11-03 | Updated: 2026-11-03

**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 see | Do this |
| --- | --- |
| No prompt appears | Interrupt during the first seconds after reset. |
| Cannot interrupt at all | Reflash the firmware. |

## Related

[Thonny cannot connect](https://roboticsengineering.in/fix/thonny-cannot-connect-esp32-micropython/), [ESP32 boot mode](https://roboticsengineering.in/fix/esp32-wrong-boot-mode-waiting-for-download/).

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.
