When you say it cannot connect, do you mean that you can type in the WiFi password and it connects to your WiFi, but it doesn't ever let you load any web pages? Or do you mean it won't even connect to your WiFi?
The first one is likely a DNS resolution issue. The second one could be a number of possible issues, but usually it's due to typing in the wrong WiFi passphrase.
Try: ping 64.233.185.138 -c 10
Then try: ping google.com -c 10
If the first one works, but the second one doesn't, it's a DNS resolution issue.
sudo apt-get install --reinstall network-manager (this command will reset ur wifi settings)
if none of these steps work, u might consider using other netwrok manager. u can install wicd using sudo apt install wicd after its installation gets completed, type sudo systemctl restart NetworkManager