Error NW-31246-6 means your PS4 or PS5 cannot connect to the PlayStation Network due to a network or DNS issue. To fix it try the following steps in order:
Check PSN server status at status.playstation.com — if PSN is down, wait for it to come back online
Restart your console and router — fully power off your PS4 or PS5, unplug your router for 60 seconds, plug it back in, then turn your console back on
Change your DNS settings — go to Settings → Network → Set Up Internet Connection → Advanced Settings → DNS Settings → Manual and enter Primary DNS: 8.8.8.8 and Secondary DNS: 8.8.4.4
Use a wired connection — connect your console directly to your router with an Ethernet cable instead of Wi-Fi
Test your internet connection — go to Settings → Network → Test Internet Connection to identify exactly where the connection is failing