As long as the coconut is a fresh coconut that has not been cut up or cut open the fresh coconut can last at room temperature for up to 4 months.
But once you cut up the coconut then the cut up coconut needs to be kept refrigerated or it will spoil.
Bacteria can grow rapidly on the coconut when it's left out at room temperature for longer than a couple hours once you cut it up.
But a fresh coconut that has not been cut up or cut open is safe at room temperature for up to 4 months as bacteria cannot grow inside it.
The coconuts stay out of the refrigerator while they are growing so they are safe when left out but eat the coconut within 4 months.