Ergh.... that error is my number one enemy.
Basically it’s not you. It’s more than likely your isp.
Some work around steps:
1) open up command prompt on your computer and type
/ipconfig flushdns
That will wipe all the dns address/names so when your computer goes to a webpage it has to look it up again. That used to work for me 8 times out of 10.
2) get a new isp, but, it may also be the connections in your neighbourhood are faulty. (Which is what my main problem was, wasn’t until they re did the connections in my area that it got fixed)
3) try a VPN. Sometimes this will help bypass the isp dns.
4) update java and assign minecraft to use the updated java, and not its own internal version.
Other than that, I’ll try and find another link where I asked for help.