Gas heater lights then goes out
Could be a defective thermocouple, a sensor to measure the temperature (either it can be too far away the pilot, push it close to it if the case, or is already defective, you could replace it).

You could also check the pilot tube, it can be blocked.