Not connected. Select a board and port to connect automatically

Keep getting "Not connected. Select a board and port to connect automatically." message when opening the serial monitor. Anybody got any idea how to fix this? my sketches verify and upload fine as the blink programme has got the LED on my Raspberry pico 2040 so the board and com port are obviously connected.
When I upload a sketch that requires reading data from an ultrasonic sensor I need the serial monitor to write the data but not sure how to fix this. Any suggestions would be appreciated.

Thank you.

Despite the message, are you sure that the Serial monitor does not actually work ?

Without more information, I wouldn't be able to say whether it is what @seanye encountered, but there is a known bug that can cause this message to appear unexpectedly:

In the case of that bug, the output will still be shown in the Serial Monitor, but you will not be able to send data back to the Arduino board via Serial Monitor: