Diagnosis
F 51 means the exhaust thermistor is reading out of range. It's either failed, or the exhaust path is severely restricted, causing overheating.
How to Fix It
First, check the entire venting system from the dryer to the outside. Disconnect it. Ensure it's clear, not crushed, and less than 35 feet long. Clean it thoroughly.
If That Didn't Work
The thermistor itself is on the blower housing. Unplug dryer. Disconnect the wire harness from it. Test resistance. At room temp, it should read around 10k ohms. If it reads open or short, replace the exhaust thermistor (part # 310643).
Heads Up
Ignoring this code risks a fire. A restricted vent is the most common cause. Clean it every year.