Solving a bug, whether in code or anywhere else in life, takes the same skills. Beginner's mind is one of them.
Every bug stems from a discrepancy between how the system actually works, and how you think it works. In order to solve a bug, you have to identify the part of your understanding that's incorrect or incomplete.
How do you look for something you don't know how to look for?
Something you think know hides the thing you don't know. Beginner's mind starts by putting your entire mental model on probation. Treat everything you think you know with a baseline suspicion, regardless of how fundamentally true it seems.
You know how tech support always starts by asking you to confirm everything's plugged in, and then makes you reboot twice? Beginner's mind is why. You can waste an infinite amount of time if you don't check the most obvious cases first.
To shift into beginner's mind, start by postponing your intention to fix anything. Successful debugging starts by understanding alone. The desire to fix gets in the way.
Novices often try to find and fix the bug at the same time. They throw stuff at the problem in the hopes that something will stick. This makes everything worse; before, you had case x you didn't understand, now you have case x and also y + z + some other random stuff.
Remember debugging means identifying some way in which you are wrong. The process has an element of an exercise in humility. I've seen talented but egotistical programmers stumped by a bug because they can't admit they could be wrong. The problem isn't exactly staring them in the face – it's subtle – but they are willfully blind to it.
All of these things apply to everyday life. Doctors have a principle, "primum non nocere" – first, do no harm. The first lesson in surfing has you sit on the beach and just watch the waves. Asking questions works better with other people than placing demands. And so forth.
Another valuable life lesson from programming.