The direct answer
Your pilot lights, burns while you hold the knob, then dies the moment you let go. That's the classic thermocouple story, and it's true maybe seven times out of ten.
The thermocouple is a pencil-thin metal probe that sits in the pilot flame. When it heats up, it makes a tiny electrical signal that tells the gas valve, "the flame is real, keep the gas flowing." When it weakens, the valve stops trusting it and shuts the gas off. Pilot dies.
The second most common cause is a dirty pilot orifice. After a furnace sits idle all summer, dust and cobwebs choke the tiny opening, the flame goes weak and yellow, and it can't heat the thermocouple enough.
This is gas work, not a DIY job. A licensed technician should service the furnace, even on a standing-pilot unit.
What's actually going wrong
Think of this as a short chain: gas gets to the pilot, the pilot flame heats the thermocouple, the thermocouple holds the valve open. A break anywhere in that chain drops the pilot.
Skip the parts shopping on this one. A thermocouple sits in the gas path, so a licensed technician should source and install it. See the 2026 cost range above for what a service call runs.
The connection point matters too. The thermocouple screws into the gas valve with a small nut, and if it's loose (common after any past service work), the signal gets weak even when the part is fine.
Drafts are the sneaky one in summer. An open basement window, a running dryer, or a bathroom exhaust fan can pull enough air through the space to snuff a small flame. If your pilot flickers visibly, look for airflow before you condemn any parts.
The gas valve itself is last on the list because it's the most expensive and the least likely. When the magnetic coil inside weakens, no thermocouple on earth will hold it open. That's a pro diagnosis and often a replace-the-furnace conversation.