Are you using any anti-virus apps, cleaing/optimizer apps, third party security software, a VPN, or browser extensions? Any or all of these may cause such a problem. If you have any of these apps installed, then uninstall them by following the developer's instructions since these types of apps are not needed on a Mac. These types of apps usually causes more problems than they solve.
The only time to use a VPN app is when you need to connect to your business or school network to access certain services or systems. Otherwise a VPN is not providing you the privacy you think it does.
If this does not help, then try creating a new macOS user account. Log out of your main user account, then log into the new user account. See if you have the same issue. If this works, then you have some sort of configuration issue with the main user account (login item, or browser extension, or preference/configuration setting).
Also try booting into Safe Mode to see if you can connnect. If Safe Mode works, then it most likely means you have some third party software installed which is causing a problem.