A non-functioning power button on your iPhone can be frustrating, but there are a few things you can try to fix it before resorting to a repair shop. Here are some steps you can follow:-
1. Remove Case and Screen Protector:- A bulky case or screen protector might be interfering with the button's movement. Try removing them and see if the button works properly.
2. Clean the Power Button:- Dirt or debris around the button can hinder its functionality. Use a soft, dry cloth to clean the button and surrounding area. You can also try a cotton swab dipped in a small amount of rubbing alcohol (isopropyl alcohol), but be sure not to let any liquid seep into the phone.
3. Force Restart:- This can sometimes resolve temporary software glitches that might be affecting the button. The method for a force restart depends on your iPhone model. You can find specific instructions by searching online for "force restart iPhone [your model]".
4. Enable AssistiveTouch:- AssistiveTouch provides an on-screen virtual button that can replicate many functions, including locking the screen and powering off the phone (Settings > Accessibility > Touch > AssistiveTouch). This can be a helpful temporary solution while you troubleshoot the physical button.
More details instruction below.
https://thegeekpage.com/power-button-not-working-on-iphone-fix/