A pilot that will not hold usually is not the pilot. It is the safety switch that is supposed to prove it is lit.
Relighting the pilot over and over is the natural response, and it is also the least useful one. If the pilot goes out again within a minute of releasing the button, the pilot itself was never the problem — something downstream of it is shutting the gas off, and it will keep doing that until whatever is actually wrong gets fixed.
A thermocouple is a safety sensor that sits in the pilot flame and proves to the gas valve that the pilot is actually lit. When it works, the valve stays open to the main burner. When it degrades, corrodes, or drifts out of position, it stops reliably sensing the flame even though the flame is fine, and the valve shuts pilot gas off as if the flame had gone out — which reads, from where you are standing, as a pilot that will not stay lit.
The pilot lights without trouble, stays lit while you hold the button down, and goes out within seconds to about a minute after you release it. Visible corrosion or soot on the sensor tip is a common giveaway once someone has the panel open.
A draft blowing across the pilot — an open door to an unheated space, a vent pulling air wrong — can blow a healthy pilot out too, and that is a different fix than a part. A failing gas control valve or, on newer electronic-ignition tanks, a control module fault can produce a similar symptom with a different repair behind it.
Repeatedly cycling gas to a pilot that will not hold is not itself usually dangerous, but it is not a routine you should be settling into either. If it needs relighting more than once, that is the point to get it looked at rather than the point to memorize the relighting instructions.
A thermocouple is inexpensive and a quick swap for a licensed plumber. A failing gas control valve is a larger part, and depending on the tank's age, that is sometimes the point where a straight comparison against replacement is worth having rather than sinking a bigger repair into an older tank.
Describe what the tank is doing and get matched with a licensed plumber who can tell you what it actually needs.
Get Matched With a PlumberA quick description is enough — we will follow up to narrow it down and get someone out.