The pilot light on a boiler is regulated by a thermocouple probe, so if the pilot doesn't stay lit, you will have to replace the thermocouple. The thermocouple sensor sends a signal to the gas valve that there is a presence of a flame which allows the gas to be released. The process involving replacing a thermocouple can be complex if you are unfamiliar with the parts of a boiler system. If you are uncertain at all about your abilities to safely and confidently replace a thermocouple, seek the help of a professional.
Turn off the power to your boiler. Remove the cover to the boiler to access the inner workings. Turn the brown knob on the gas valve so the arrow points to "pilot." Make sure you know the difference between the gas valve, which has wires coming out of it, and the gas cock which is the gas shut off to the boiler.
Remove the burner cover carefully because it may be hot. Check to see if the pilot is still out. If it is not out, your thermocouple may not be completely used up but will be soon and should be replaced. Use a wrench to loosen the copper thermocouple nut. If the pilot light goes out, you can continue. If the pilot light does not go out, turn the gas cock to "off" or "stop," and call a professional because you have a defective gas valve which needs to be replaced by an expert.
Use a wrench to remove the pilot tubing from the gas valve in order to replace the thermocouple. Remove the burner from the boiler by lifting the rear of the burner and pulling it forward to free it from the brass fittings. Remove the old thermocouple by unscrewing it or pulling it out. Dispose of the old thermocouple. Wipe off any white powder in the pilot orifice where the thermocouple was plugged in with a clean rag.
Use a wrench to remove the nut attached to the pilot assembly. Wipe away any white powder inside this area as well. Replace the nut into the pilot assembly, and tighten with the wrench. Attach the new thermocouple to the pilot orifice with whichever one of the two adaptors fits the pilot orifice. Ensure that the thermocouple is fully seated into the pilot orifice for a good signal to the gas valve.
Put the pilot assembly back in its designated location. Replace the burner, ensuring that it is in place right side up. Reconnect the pilot tubing to the gas valve and tighten with a wrench. Connect the new copper thermocouple nut to the gas valve. Tighten the nut, but do not over tighten it. Apply a thin coat of soapy water with a sponge to the nut that connects the pilot tubing to the gas valve.
Depress and hold the red pilot light button. Observe whether there are any bubbles seeping from the nut in the dish soap to ensure the nut is secured properly and no gas is leaking. Release the button and wait 5 minutes. Press and hold the button again. Light the pilot with a match while holding the button down. Release the button after one minute after lighting the pilot. If it goes out, call a professional. If it stays on, replace the burner cover. Stand up and make sure you are not in front of the boiler. Turn the brown knob on the gas valve on and the gas cock on. Turn the power on and replace the boiler cover.
Be aware of the location of the pilot while removing the burner to avoid damaging it.