# Board connection lost - upload failed

**URL:** <https://forum.arduino.cc/t/board-connection-lost-upload-failed/970711>\
**Category:** IDE 2.x\
**Created:** [March 18, 2022, 1:25pm UTC](https://forum.arduino.cc/t/board-connection-lost-upload-failed/970711 "2022-03-18T13:25:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xinonix](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/xinonix/32/1099305_2.png) [@Xinonix](https://forum.arduino.cc/u/Xinonix)\
**Post date:** [March 18, 2022, 1:25pm UTC](https://forum.arduino.cc/t/board-connection-lost-upload-failed/970711/1 "2022-03-18T13:25:02Z")

</div>

In IDE 2.0 RC5 I have problem with board connections.

- When starting the IDE I might see the board as connected or not. The problem might get resolved by unplugging/plugging the USB cable.
- During development this might happen at random and then unplug/plug does not always resolve the issue.
- During upload I might lose connection and am unable to resolve problem unless I reboot my PC
- Serial monitor does interfere with connection but this seems to be rather random, it might fail one time and work the next. The message related to Serial monitor connections are not consistent and do not always reflect what the system sees (No connection but showing output).

---

<div class="post-metadata">

**Author:** ![ptillisch](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@ptillisch](https://forum.arduino.cc/u/ptillisch)\
**Post date:** [March 19, 2022, 1:32am UTC](https://forum.arduino.cc/t/board-connection-lost-upload-failed/970711/2 "2022-03-19T01:32:43Z")

</div>

> [@Xinonix](#):
>
> - When starting the IDE I might see the board as connected or not. The problem might get resolved by unplugging/plugging the USB cable.
> - During development this might happen at random and then unplug/plug does not always resolve the issue.

Problems related to whether the port of your board is correctly shown in the related menus (Board Selector dropdown menu, " **Select Board**" dialog, **Tools \> Port** menu) are likely related to the low level [**serial-discovery** tool](https://github.com/arduino/serial-discovery) used by the Arduino development software to find ports.

If you would like to do some troubleshooting, you can check whether that tool is behaving and able to see the port of your board.

❗ NOTE: This will not solve the problem. This is only intended to possibly gather some more information about the problem, which might provide a clue that leads to a solution.

I'll provide the instructions here:

I seem to remember you are using Windows, so I have provided the Windows-specific instructions. If I misremembered, let me know and I'll provide the instructions for your OS.

During all this, keep an eye out for anything that doesn't match the expected behavior as described at each step.

1. Open the following folder in Windows " **File Explorer**":

```plaintext
C:\Users\<username>\AppData\Local\Arduino15\packages\builtin\tools\serial-discovery

```

**ⓘ** Note that the `AppData` folder is hidden by default in " **File Explorer**". You can make it visible by opening the " **View**" menu, then checking the box next to " **☐ Hidden items**".
2. The `serial-discovery` folder will contain a subfolder for each of the versions of **serial-discovery** which are installed on your computer.  
For example:

```plaintext
serial-discovery/
├── 1.3.0/
├── 1.3.0-rc1/
└── 1.3.2/

```

3. Hold the **Shift** key while clicking the right hand button on the mouse on the folder with the highest version (`1.3.2` in the example above).
4. From the context menu, click " **Open PowerShell window here**".  
PowerShell will now open.
5. Type the following command:

```plaintext
serial-discovery

```

6. Press the **Enter** key.  
**serial-discovery** will now start. There won't be any obvious sign of this other than that there is no longer a command prompt at the cursor in the terminal.
7. Type the following command:

```plaintext
HELLO 1 "arduino-cli 0.20.2"

```

8. Press the Enter key.  
You should now see a response printed exactly like this:

```json
{
  "eventType": "hello",
  "protocolVersion": 1,
  "message": "OK"
}

```

9. Unplug your Arduino board from your computer if you have it plugged in.
10. Type the following command:

```plaintext
START_SYNC

```

11. Press the Enter key.  
You should now see a response printed exactly like this:

```json
{
  "eventType": "start_sync",
  "message": "OK"
}

```

You might also see some additional objects in the output depending on which serial ports are available on your computer.
12. Plug your Arduino board into your computer  
You should now see a response printed that looks something like this:

```json
{
  "eventType": "add",
  "port": {
    "address": "COM42",
    "label": "COM42",
    "protocol": "serial",
    "protocolLabel": "Serial Port (USB)",
    "properties": {
      "pid": "0x804e",
      "vid": "0x2341",
      "serialNumber": "EBEABFD6514D32364E202020FF10181E"
    }
  }
}

```

This is only an example of what you might see. The output will be different depending on the board you connected.
13. Unplug your Arduino board from your computer  
You should now see a response printed that looks something like this:

```json
{
  "eventType": "remove",
  "port": {
    "address": "COM42",
    "protocol": "serial"
  }
}

```

This is only an example of what you might see. The `address` field value should be the same as the "`add`" event you saw when you plugged the board in.

You should continue to see the same results if you repeat steps (12) and (13).

Once you are done with your experiments with the " **serial-discovery**" tool, follow these instructions to exit:

1. Type the following command:

```plaintext
STOP

```

2. Press the Enter key.  
You should now see a response printed exactly like this:

```json
{
  "eventType": "stop",
  "message": "OK"
}

```

3. Type the following command:

```plaintext
QUIT

```

4. Press the Enter key.  
You should now see a response printed exactly like this:

```json
{
  "eventType": "quit",
  "message": "OK"
}

```

You should now be back at the shell command line.

---

<div class="post-metadata">

**Author:** ![ptillisch](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@ptillisch](https://forum.arduino.cc/u/ptillisch)\
**Post date:** [March 19, 2022, 1:54am UTC](https://forum.arduino.cc/t/board-connection-lost-upload-failed/970711/3 "2022-03-19T01:54:00Z")

</div>

> [@Xinonix](#):
>
> - Serial monitor does interfere with connection but this seems to be rather random, it might fail one time and work the next.

Is it this one?

> <https://github.com/arduino/arduino-ide/issues/726>
>
> \## Describe the bug
> 
> The Arduino IDE uses the serial ports of Arduino boards i…n two different ways:
> 
> \- Uploading sketches
> \- Communication via Serial Monitor
> 
> The port can not be used for both of these things simultaneously. The IDE handles the condition of Serial Monitor being open when an upload is started automagically like so:
> 
> 1. Close port in Serial Monitor
> 1. Complete upload process
> 1. Reopen port in Serial Monitor
> 
> :bug: This works as expected in the first IDE window you open, but it no longer works in subsequent windows.
> 
> \*\*\*NOTE\*\*\*: although similar, this is different from https://github.com/arduino/arduino-ide/issues/586 because it occurs even when the port is not open in a Serial Monitor/Serial Plotter of another IDE window.
> 
> \## To Reproduce
> 
> 1. Connect an Arduino board to your computer.
> 1. Select the appropriate board and port.
> 1. Select \*\*Tools \> Serial Monitor\*\* from the Arduino IDE menus to open Serial Monitor.
> 1. Select \*\*Sketch \> Upload\*\* from the Arduino IDE menus.
> :slightly\_smiling\_face: Upload succeeds as expected.
> 1. Select \*\*Tools \> Serial Monitor\*\* from the Arduino IDE menus to close Serial Monitor.
> This is necessary to avoid https://github.com/arduino/arduino-ide/issues/586
> 1. Select \*\*File \> New\*\* from the Arduino IDE menus.
> 1. Select \*\*Tools \> Serial Monitor\*\* from the Arduino IDE menus in the new window.
> :bug: Note that there is an unexpected banner in Serial Monitor:
> \> Not connected. Select a board and a port to connect automatically.
> 1. Select \*\*Sketch \> Upload\*\* from the Arduino IDE menus.
> :bug: Upload fails with an error something like "avrdude: ser\_open(): can't open device "\\\\.\\COM7": Access is denied."
> 
> \## Expected behavior
> 
> Upload with Serial Monitor open in the same IDE window to always be handled automagically.
> 
> \## Desktop
> 
> \- OS: Windows 10
> \- Version: 2.0.0-rc3
> Date: 2021-12-22T15:46:56.004Z
> CLI Version: 0.20.2 \[13783819\]
> 
> \## Additional context
> 
> It is not necessary to leave the original window open to reproduce the bug. It occurs even if that window is closed.
> 
> \---
> 
> I bisected the issue to https://github.com/arduino/arduino-ide/commit/767b09d2f10cab78b07754039ebb749d55b45d8d (it does not occur at https://github.com/arduino/arduino-ide/commit/88397931c5b704516e881959f6e7ce106094d14d).
> 
> \---
> 
> Originally reported at https://forum.arduino.cc/t/upload-failed-when-serial-monitor-is-open/940255

> [@Xinonix](#):
>
> The message related to Serial monitor connections are not consistent and do not always reflect what the system sees (No connection but showing output).

I'm sure it is this bug:

> <https://github.com/arduino/arduino-ide/issues/753>
>
> \## Describe the bug
> 
> The Serial Monitor and Serial Plotter communicate to the …user when the currently selected port is not connected (e.g., the user unplugged their Arduino board).
> 
> :bug: The Serial Monitor and Serial Plotter of all except the first Arduino IDE window of the session with a given port selected give this indication even when the port is indeed connected to the computer.
> 
> \## To Reproduce
> 
> \### Preparation
> 
> Upload a sketch to your Arduino board that sends plottable serial output:
> 
> \`\`\`cpp
> void setup() {
> Serial.begin(9600);
> }
> void loop() {
> Serial.println(random(100));
> delay(500);
> }
> \`\`\`
> 
> The bug will occur regardless of which sketch is on the board. This sketch is only intended to make the behavior easier to observe.
> 
> \### Observe baseline working state
> 
> This procedure is not required to reproduce the bug. It is only intended to prove that the issue does not occur in the first window of the session.
> 
> 1. Open the "\*\*Serial Monitor\*\*" view (\*\*Tools \> Serial Monitor\*\*).
> :slightly\_smiling\_face: Notice that no disconnected indicators are shown, as expected.
> !\[image\](https://user-images.githubusercontent.com/8572152/149646178-fe794c3f-08ae-4449-aa23-2f4b62bbbf6a.png)
> 1. Open the "\*\*Serial Plotter\*\*" window (\*\*Tools \> Serial Plotter\*\*).
> :slightly\_smiling\_face: Notice that no disconnected indicators are shown, as expected.
> !\[image\](https://user-images.githubusercontent.com/8572152/149646187-e1220e52-c6f1-4e8f-be42-6bc8879a6c3a.png)
> 1. Close the "\*\*Serial Monitor\*\*" view (\*\*X\*\* icon).
> This is not mandatory to reproduce the bug. It is done so that Serial Monitor will not be open in the first window of the next session, which might give the impression that is a required condition to reproduce the bug.
> 1. Select \*\*File \> Quit\*\* from the Arduino IDE menus.
> This is not mandatory to reproduce the bug. It is done so that it is clear that none of the operations performed during this procedure are required conditions to reproduce the bug.
> 
> \### Observe bug
> 
> 1. Start the Arduino IDE.
> 1. If not already selected, select your board and port from the board/port selector dropdown.
> 1. Select \*\*File \> New\*\* from the Arduino IDE menus.
> This loads the second window of the current IDE session.
> 1. Open the "\*\*Serial Monitor\*\*" view (\*\*Tools \> Serial Monitor\*\*).
> 1. Select "\*\*9600 baud\*\*" from the "\*\*Serial Monitor\*\*" view's baud rate menu.
> :slightly\_smiling\_face: Notice that random numbers are periodically printed to the Serial Monitor view's output field, as expected.
> :bug: Notice that there is an unexpected banner in Serial Monitor:
> \> Not connected. Select a board and a port to connect automatically.
> !\[image\](https://user-images.githubusercontent.com/8572152/149645768-59bdbafd-d3bb-4ebb-94f4-2e5ffff244ed.png)
> 1. Open the "\*\*Serial Plotter\*\*" window (\*\*Tools \> Serial Plotter\*\*).
> :slightly\_smiling\_face: Notice that random numbers are periodically plotted in the Serial Plotter, as expected.
> :bug: Notice that the Serial Plotter window title has the "\*\*(disconnected)\*\* suffix.
> :bug: Notice that a "\*\*Board disconnected\*\*" notification is shown in the Serial Plotter window.
> :bug: Notice that some Serial Plotter UI elements are disabled.
> !\[image\](https://user-images.githubusercontent.com/8572152/149645608-d075e439-3cd8-46e4-83f9-ae5f56ff4366.png)
> 
> \## Expected behavior
> 
> Serial Monitor and Serial Plotter of subsequent IDE windows to connect to the selected port.
> 
> \## Desktop
> 
> \- OS: Windows 10
> \- Version: 2.0.0-rc3-snapshot.35e5da5
> Date: 2022-01-13T17:15:54.562Z
> CLI Version: 0.20.2 \[13783819\]
> 
> \## Additional context
> 
> \---
> 
> I believe this issue, https://github.com/arduino/arduino-ide/issues/752, and https://github.com/arduino/arduino-ide/issues/726 to all be different symptoms of the same bug. I decided to open a separate issue for each distinct symptom because users affected by one symptom will not associate it with the report for another symptom, making the bug more difficult to support and track.
> 
> \---
> 
> I bisected the related issue https://github.com/arduino/arduino-ide/issues/726 to https://github.com/arduino/arduino-ide/commit/767b09d2f10cab78b07754039ebb749d55b45d8d (it does not occur at https://github.com/arduino/arduino-ide/commit/88397931c5b704516e881959f6e7ce106094d14d).
> 
> \---
> 
> Originally reported by @hpssjellis at:
> https://github.com/hpssjellis/my-examples-for-the-arduino-portentaH7/tree/master/ide2.0#:~:text=why%20does%20it%20say%20it%20is%20not%20connected
> and by @DroneBotWorkshop at:
> https://forum.arduino.cc/t/rc3-serial-plotter-monitor-show-disconnected-when-they-are-not/947524

---

<div class="post-metadata">

**Author:** ![Xinonix](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/xinonix/32/1099305_2.png) [@Xinonix](https://forum.arduino.cc/u/Xinonix)\
**Post date:** [March 20, 2022, 2:08pm UTC](https://forum.arduino.cc/t/board-connection-lost-upload-failed/970711/4 "2022-03-20T14:08:38Z")

</div>

I ran the commands as requested, they all show similar requests as yours.  
I started arduino and all looks fine. I restart arduino and get:  
 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/c/2/e/c2efbc87e8b8d64d43d9d4cd12abe2acb4c4748f.png)

No board connected while the monitor shows:  
 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/0/c/6/0c66f43f88fc5c34cddd7ad532670d6b4b3f9479.png)

unplug /plug while Arduino is running results in:

```cpp
{
  "eventType": "remove",
  "port": {
    "address": "COM5",
    "protocol": "serial"
  }
}
{
  "eventType": "add",
  "port": {
    "address": "COM5",
    "label": "COM5",
    "protocol": "serial",
    "protocolLabel": "Serial Port (USB)",
    "properties": {
      "pid": "0xEA60",
      "serialNumber": "0001",
      "vid": "0x10C4"
    }
  }

```

and arduino shows:  
 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/9/4/b/94bb60b1b8125d12b3145ac2e6d9f1d819815ff1.png)

I hope this helps.

---

<div class="post-metadata">

**Author:** ![ptillisch](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@ptillisch](https://forum.arduino.cc/u/ptillisch)\
**Post date:** [March 20, 2022, 9:57pm UTC](https://forum.arduino.cc/t/board-connection-lost-upload-failed/970711/5 "2022-03-20T21:57:59Z")

</div>

The ❌ indicates that you have a board selected, but no port selected.

The ⚠ indicates you have a board and port selected, but that the Arduino IDE is not able to verify that the port selection is correct for that board based on its USB VID/PID.

Since the ESP32 boards use the non-unique VID/PID provided by the manufacturer of their general purpose USB to serial adapter chip (e.g., WCH CH340, Silicon Labs CP2102), there is no way for the IDE to know what board is using that VID/PID, and so this ⚠ icon is normal and expected for your ESP32 board.

Just make sure you have selected the correct port from the **Tools \> Port** menu in the Arduino IDE.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [September 16, 2022, 9:58pm UTC](https://forum.arduino.cc/t/board-connection-lost-upload-failed/970711/6 "2022-09-16T21:58:32Z")

</div>

Closed on September 16, 2022, 9:58pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
