I also recently got PS4 and PSN worked fine for me. After like a day , it showed the error code. So all I did was change NAT from Cone to Symmetric in settings , and it it worked. Now I can sign in without any issues. Actually it doesn't really change the NAT type , but it somehow does the job for being able to sign in. Hope it helps!