-When you press the power button on your PS4 the blue light comes on, then a few seconds later the console turns off by itself. Your fan may or may not come on and the number of seconds that the PS4 will stay on also varies. If your PS4 does not turn off or the blue light just blinks then you don't have this problem. Let's take a look at what might be causing this problem
How to fix a PS4 that turns on then right back off
There are several common causes of this problem. One of the things that can cause it is a bad power supply. Sometimes something in the power supply goes bad and that doesn't let the right amount of power get to the console. This makes the console turn right back off.
Another common cause of this problem is faulty solder joints and/or faulty chips on the motherboard. There is no good way to tell which of these is the problem. Really the only way to know for sure what is causing it is to rule each of these out one at a time.
While the best long-term fix for this problem is a reball from a reputable repair facility, there are two things you can try that may get your PS4 working for a while. These likely will not fix it for a long period of time but may get it working long enough to get your data off of it.
You can try hitting it against your knee or against the floor. Obviously you don't want to hit it so hard that it breaks something.
You can set the console up on it's side and try to turn it on.
If neither of those options work another option that may work is adding pressure to the APU clamp. This will help to restore the lost connection between the APU and motherboard. This video explains it well:
These options don't work often, but they do sometimes and since they are easy to do it's worth a try.