If other devices also have no Internet access, your problem is most likely with your Wi-Fi router/modem or Internet service provider.
If the Internet works on other devices, meaning if your other device successfully connects to the Wi-Fi network, your problem lies with your Mac.
If you have other devices (other your Mac or PC computers, iOS or iPadOS devices, or your friend’s phone, etc), try connecting to the same Wi-Fi network with another device:
Does this problem occur with more than one Wi-Fi device? Answering this is important because your Internet problem may be related to the network in question or it may be related to your Mac.
There are some questions you need to answer:
How To Disable Wi-Fi Auto-Join in macOS.
Your Mac or iPhone Can’t Connect to a Public Wi-Fi Hotspot (Captive)?.
How To Fix Slow Wi-Fi Problems On Your Macbook.
Simply, after each step, use an Internet browser to connect to any website on your Mac. After trying each step below, test your Mac again to see if the Internet access is working again. There can be several reasons why this problem may occur. This article explains what you can do to fix when your Mac is connected to your Wi-Fi network but has no Internet access. This is an important problem because unless it is resolved, webpages in Safari or other browsers will not open, other Internet apps (FaceTime, Mail, Messages, App Store) will not work. You check the status of your wireless network connection, and it shows that your Mac is currently connected to Wi-Fi. Because there’s no working Internet connection. It is a common problem: Your Mac does not connect to the Internet.