2012 sportsman hot check engine problem

Hi everyone. I have a 2012 sportsman 500 and the hot check engine has been flashing. This very fast after starting even when the engine is cold. While riding it will come on and off multiple times and then it stops. When I unplug the temperature sensor the fan does not come on but the fan has came on recently while idling for a period of time. Any help is appreciated!