One evening I noticed my M1 Max MacBook Pro battery level was 14%. That was odd, because I charge it overnight and hadn’t used it much during the day. I plugged its charger into a USB port and double-checked the battery icon in the status bar, which I usually don’t bother to do. It didn’t show the lightning bolt that indicates the computer was charging.
I checked that the power receptacle that the charger was plugged into was good, I reconnected the cable at each end, swapped the cable for a spare, swapped the charger for a spare, then swapped both and plugged into a different receptacle, but it still wasn’t charging. I didn’t have my MagSafe cable with me (I was away from home) so I couldn’t try that. With thoughts of a damaged USB-C port or other hardware and with only 13% battery left, I shut down to consider the situation. Then I thought “Maybe software!” and restarted the machine, still plugged in. Logged in, and voila: it started charging!