What happens if you manually set the DNS server to a known public DNS server, such as the one at 188.8.131.52 or the one at 184.108.40.206?
If that works well, then the issue was bad DNS settings. This may often be caused by DHCP. The best way to troubleshoot that further, if desired, may be to set the computer's "DNS server" settings back to automatic, and wait for the problem to occur again. Then, when the problem does occur again, run "IPConfig /ALL" and look for a line (or multiple lines) saying "DHCP Server . . . . . . . . . . . :"
Then, the device at that IP address is likely the culprit of the problems. Go to that address with HTTP (in other words, type that address into a web browser) and you'll often find the device identifies itself.
The cause is often a device, such as a wireless access point, that tries to automatically figure out what DNS information it should use, and having a problem with that. Then, the device passes on that bad DNS information to other devices on your network.
The most ideal solution will be to fix the device, and the details on how to do that will depend on specific details like just what type of device is being used. One way to try solving the problem, which is probably the best fix if this easy approach resolves the problem for you, might be just applying an available authentic firmware update. Other solutions might involve improving the quality of the Internet connection that this device experiences.
An alternative solution, which is probably satisfying enough for most scenarios, may be to just go to that device's DHCP settings and tell it what DNS servers to hand out. Instead of "automatically detected DNS servers", but in something reliable like 220.127.116.11 or 18.104.22.168 (and make sure that you successfully save your changes). If a more satisfying solution (which actually fixes an identified problem) isn't found, this workaround is often an available approach which can work quite sufficiently well.