I had one of these trucks that did the exact same thing. The coolant temp sensor leaked just enough to corrode the contacts on the plug. It is pretty easy to check, unplug the sensor and look for green corrosion. If it is nasty, replace the sensor, clean the contacts and reassemble.