Hello there, franky333!
Thanks for reaching out to the Apple Support Communities! It sounds like your Mac is giving you an error when it restarts. Check out this article If your Mac won’t go to or stay in sleep. This article will give you some steps you can try for issues with your Mac.
We also recommend taking a look at this article with steps to follow for How to use safe mode on your Mac. This will perform checks and stop certain software from starting up automatically. Once you are in safe mode, test to see if you have the same issue.
Let guys know the results and have a great day!