Check status.playstation.com to see if PSN is down; if it shows no problems, restart your console, router and modem and test ...
A number of problems can result in a PlayStation 4 not connecting to WiFi. A PS4 won’t connect to WiFi with incorrect login credentials, incorrect DNS settings, or during PlayStation Network server ...