To story goes to the time when lord Krishna was born in Nandgaon. Hearing the news of the birth many saints and gods visited Nandgaon to see Lord Krishna, one among them being Shanidev. Everyone was allowed to have Krishna's darshan except Shanidev. Yashoda stopped him at the door and saying that her son would be frightened at the sight of Lord Shani.
Shanidev was highly disappointed and went to the nearby forest and prayed, "O God! I am your servant. You have appointed me to judge and punish sinners according to their karmas. Then why does everybody think of me as being malignant and cruel; why do they avoid even my shadow? Today, when all gods and demi-gods could enjoy the bliss of your darshan, I am denied that right and benediction.
" Touched by his prayer lord Krishna manifested Himself to him. He advised him to stay put near Nandanvan and granted him the boon that anyone who came to his temple to pray would immediately be freed from all worries and afflictions. That part of the forest where Krishna appeared before Shanidev, has since been called Kokilavan and one can visit the renowned and ancient temple of Lord Shani (Saturn) today which is just six km from Kosi (UP) on the Nandgaon-Barsana road.