Coconuts will only grow on the land near the beach. If you plant them too far away from the beach they always die.
They won't grow right next to the cliff or right next to a house.
I think you have been unlucky.
I always plant the coconuts in the earth (not sand) - the space right behind the line where the sand becomes earth. They usually grow there ok - but I always make sure not to plant next to a cliff or near one of the sign posts - because that is where an animal's house will appear if a new character moves into town.
One other thing that's guaranteed to work is if you have an existing tree - sapling or fruit growing very near the beach area. If you chop that down and plant the coconut in the hole the tree was growing in, it will usually survive too - just as long as it is not too far from the beach.
Good Luck