Safari and desktop apps have connectivity issues, but chrome and ping work I have a 16 inch Mac book Pro, which I have been using for the past 8 months.
It is connected to my home wifi network. In my home wifi network there are other devices like a 15 inch Mac book Pro, couple of iPhones, Amazon Firestick, Alexa etc and all of them are working properly without any issues.
But I am facing a wired and strange issue only in the 16 inch Mac book Pro.
I am able to browse internet using Chrome and it works without any issues. But both Safari and other desktop apps like Slack, Zoom, App Store etc have intermittent network issues. It works for a few seconds, stops working for a few minutes and then works again for a few seconds before stoping again.
But Google Chrome and the ping command in iTerm work without any issues, exactly when Safari and other apps have issues.
So far I have tried to reboot the machine, clear the cache by running dscacheutil -flushcache command but nothing works.
Any idea what might be wrong and how to fix it?
The proper way on modern macOS to flush the dns cache is:
sudo killall -HUP mDNSResponder

You’ll want ensure your DNS is working well by bypassing your routers provided DNS and manually configuring Google or Cloudflare or other DNS provider on the MBP.
8.8.8.8, 8.8.4.4 is Google
1.1.1.1, 1.0.0.1 is Cloudflare
There are several other DNS providers to choose from. You definitely should use one of these on your router instead of your Internet providers DNS. Not only for privacy but also performance.
Some even setup their own DNS servers and enable DNSSEC, etc. to encrypt the DNS traffic. The Pi-hole DNS filter can block tracking, ads, and known malware sites for your entire network. Although it runs on a Raspberry Pi you can run it on other systems such as Docker, etc
Another possible problem may be a proxy. If this is an employer issued Mac it may be using a corporate network proxy even when you are not VPN connected. Companies are doing more of this due to the pandemic and work from home. If you see a Profiles icon in System Preferences (might have to search for it) then the Mac is managed with Configuration Profiles likely outside your control.
You may need to update the firmware on your router or if the router is older than 5 years consider replacing it.
You should check everything running from /Library/LaunchDaemons /Library/LaunchAgents and ~/Library/LaunchAgents for anything suspicious.