1 Samuel 22:4-5
22:4 So he had them stay with the king of Moab; they stayed with him the whole time that David was in the stronghold.
22:5 Then Gad the prophet said to David, “Don’t stay in the stronghold. Go to the land of Judah.” So David left and went to the forest of Hereth.