Could be hardware or software..
If you just manually turn on the hot end and leave it does it stay on? (if no, its a hardware problem, probably broken wire, or bad fet)
If it was fine make the printer move around back and forth on the X axis does it stay warm? (if no its probably a broken wire or bad plug and movement makes it disconnect)
Still ok, next check your gcode file for anything setting the temp to something lower or off.