warningJava ErrorsAffects: All versions
How to Fix java.net.UnknownHostException
Fix UnknownHostException by checking your internet connection, verifying server address, and flushing DNS cache.
Quick Fix
Check your internet connection and verify the server address is spelled correctly.
Error Message
java.net.UnknownHostException: Unable to resolve hostHow to Fix
1
Verify you have an active internet connection
2
Double-check the server address for typos
3
Try using the server's IP address instead of hostname
4
Flush DNS cache: ipconfig /flushdns (Windows) or sudo dscacheutil -flushcache (Mac)
5
Try changing DNS to 8.8.8.8 or 1.1.1.1
Common Causes
- DNS resolution failure
- No internet connection
- Server hostname spelled incorrectly
- DNS server unreachable
Diagnostic Steps
- Test internet by opening a website in your browser
- Verify the server address
- Try the IP address directly
- Flush DNS if needed
FAQ
Why can I browse the web but not connect to a server?
The server hostname may be misspelled, or the DNS record may not have propagated yet. Try the direct IP address.