Arduino Nano Sketch Lost after Switching to 9V Battery

My arduino nano works fine when it is connected through USB to the computer, running the sketch fine. When I switch to using an external 9v battery as its sole power source, the nano's sketch won't run (but it does turn on). I am also using an offbrand nano, an Elegoo nano, it that makes any difference. What is happening and how could I fix this problem?

What else is running from that battery?

Nothing else, just the Arduino Nano.

If I were troubleshooting this, I would first make sure the positive terminal of the battery is connected to the Vin pin. Then I would measure the 5V pin to see if I get something close to 5V.