Given where this question was posted, are you running macOS Server here? I’d tend to assume not given the version number and the hardware in the footer, and will assume that this is a macOS question, and not a macOS Server question.
Does the Mac connect while booted in Safe Mode?
If you have any add-on anti-malware apps, any add-on VPN apps, any add-on cleaner apps, or similar apps, remove all of those per the vendors’ instructions, restart, and test connectivity again.
Are there any firmware updates available for the Wi-Fi router from the Wi-Fi router vendor? If so, apply the latest of those, and test again.
Are here any filters or parental controls or similar screening-related apps or services configured within the Wi-Fi router? If so, disable all of those, and test again.
Does this Mac have more than one network connection active? Both wired and Wi-Fi wireless, for instance? If so, does this Mac connect correctly when only one network connection is active?