No one can harm you or benefit you without permission of Allāh Glory be to Him. What has been destined will come to pass.

Allāh Glory be to Him said

 وَإِن يَمْسَسْكَ ٱللَّهُ بِضُرٍّ فَلَا كَاشِفَ لَهُۥٓ إِلَّا هُوَ ۖ وَإِن يُرِدْكَ بِخَيْرٍ فَلَا رَآدَّ لِفَضْلِهِۦ ۚ يُصِيبُ بِهِۦ مَن يَشَآءُ مِنْ عِبَادِهِۦ ۚ وَهُوَ ٱلْغَفُورُ ٱلرَّحِيمُ

And if Allāh should touch you with adversity, there is no remover of it except Him; and if He intends for you good, then there is no repeller of His bounty. He causes it to reach whom He wills of His servants. And He is the Forgiving, the Merciful [Surah Yunus 10:107]

This subject comes under believing in predestination (qadaa wal-qadr). It is 6th pillar of imaan. There is no imaan without believing in it.

Allāh Glory be to Him said,

مَّا يَفْتَحِ ٱللَّهُ لِلنَّاسِ مِن رَّحْمَةٍ فَلَا مُمْسِكَ لَهَا ۖ وَمَا يُمْسِكْ فَلَا مُرْسِلَ لَهُۥ مِنۢ بَعْدِهِۦ ۚ وَهُوَ ٱلْعَزِيزُ ٱلْحَكِيمُ

Whatever Allāh grants to people of mercy – none can withhold it; and whatever He withholds – none can release it thereafter. And He is the Exalted in Might, the Wise. [Surah Faatir 35:2]

Ibn Abbas may Allah be pleased with him said

كُنْتُ خَلْفَ رَسُولِ اللَّهِ صلى الله عليه وسلم يَوْمًا فَقَالَ ‏ “‏ يَا غُلاَمُ إِنِّي أُعَلِّمُكَ كَلِمَاتٍ احْفَظِ اللَّهَ يَحْفَظْكَ احْفَظِ اللَّهَ تَجِدْهُ تُجَاهَكَ إِذَا سَأَلْتَ فَاسْأَلِ اللَّهَ وَإِذَا اسْتَعَنْتَ فَاسْتَعِنْ بِاللَّهِ وَاعْلَمْ أَنَّ الأُمَّةَ لَوِ اجْتَمَعَتْ عَلَى أَنْ يَنْفَعُوكَ بِشَيْءٍ لَمْ يَنْفَعُوكَ إِلاَّ بِشَيْءٍ قَدْ كَتَبَهُ اللَّهُ لَكَ وَلَوِ اجْتَمَعُوا عَلَى أَنْ يَضُرُّوكَ بِشَيْءٍ لَمْ يَضُرُّوكَ إِلاَّ بِشَيْءٍ قَدْ كَتَبَهُ اللَّهُ عَلَيْكَ رُفِعَتِ الأَقْلاَمُ وَجَفَّتِ الصُّحُفُ ‏”

One day I was behind the Prophet (peace and blessings of Allāh be upon him) [riding on the same mount] and he said, “O young man, I shall teach you some words [of advice]: Be mindful of Allāh and Allāh will protect you. Be mindful of Allāh and you will find Him in front of you. If you ask, then ask Allāh [alone]; and if you seek help, then seek help from Allāh [alone]. And know that if the nation were to gather together to benefit you with anything, they would not benefit you except with what Allāh had already prescribed for you. And if they were to gather together to harm you with anything, they would not harm you except with what Allāh had already prescribed against you. The pens have been lifted and the pages have dried.” [At-Tirmidhi, Saheeh]

If you go through any harm, believe that it is from Allāh Glory be to Him as a test or a punishment. And know that this punishment is very little as compare to punishment of aakhira, in order that you may repent and come back to Allāh Glory be to Him

Allāh Glory be to Him said,

وَلَنُذِيقَنَّهُم مِّنَ ٱلْعَذَابِ ٱلْأَدْنَىٰ دُونَ ٱلْعَذَابِ ٱلْأَكْبَرِ لَعَلَّهُمْ يَرْجِعُونَ

And we will surely let them taste the nearer punishment short of the greater punishment that perhaps they will repent. [Surah as-Sajda 32:21]

And know that the du’ā’ is the best solution to avert that harm. Allāh Glory be to Him said,

أَمَّن يُجِيبُ ٱلْمُضْطَرَّ إِذَا دَعَاهُ وَيَكْشِفُ ٱلسُّوٓءَ وَيَجْعَلُكُمْ خُلَفَآءَ ٱلْأَرْضِ ۗ أَءِلَٰهٌ مَّعَ ٱللَّهِ ۚ قَلِيلًا مَّا تَذَكَّرُونَ

Is He [not best] who responds to the desperate one when he calls upon Him and removes evil and makes you inheritors of the earth? Is there a deity with Allāh? Little do you remember. [Surah an-Naml 27:62]