According to the Bible, in any given case, devil can attack a person when there is rebellion against God’s Word, the Bible, in his or her life, like, by not believing Jesus as Lord & Saviour and giving heart to Him, not being water-baptized, possession of pride, jealousy, unforgiving, unkind to the poor, addiction, cheating and violence.
Consider, 1Samuel 18:9-10 (GNB): “And so he (King Saul) was jealous and suspicious of David from that day on. The next day an evil spirit from God suddenly took control of Saul, and he raved in his house like a madman….”
It is obvious that when there is rebellion, place is given to the devil to attack. So Eph 4:27 (KJV) says: “Neither give place to the devil.”
Thus, the only way to keep away the evil forces in anybody’s life is by replacing rebellion with obedience to God’s Word.
Hence, only if one is living in obedience, can the promises given in the Bible will be applicable, like, Psalms 91:10 (KJV) that says: “There shall no evil befall thee, neither shall any plague come nigh thy dwelling.”
“The safest place in the entire world is in the will of God, and the safest protection in all the world is the name of God (Jesus Christ).” - Warren Wiersbe.