I have a Minecraft server hosted in my local network, and a hostname associated to it on a dns server.

When I change the dns record and update the ip of the server (new ip, same hostname), Minecraft still uses the old ip (I see it in the log console) and therefor won't connect to the server. When I use nsloockup on my computer (I'm on OSX), the hostname resolves to the right ip.

I've tried to set -Dsun.net.inetaddr.ttl=0 and -Dnetworkaddress.cache.ttl=0 in my JVM arguments, but it makes no difference.

Is there any way to clear Minecraft cached dns or to disable dns cashing completely ?

  • No idea if this will help in anyway but maybe flush the cache of your system?
    – Timmy Jim
    Dec 23 '16 at 19:45
  • It could work, however, Minecraft doesn't care about the system's cache and has it's own cache.
    – tourdetour
    Dec 23 '16 at 21:03

Minecraft caches the IP to prevent persistent DNS queries when the host's system may not have the cache enabled. As far as I recall, mine is disabled on my system and Minecraft still caches it.

Easiest fix is to restart the Minecraft server (as well as making sure the host system it runs on has the correct IP address assigned to it when you start it up).

A more-involved fix is to use a static IP for the computer it runs on, and have the external access to it route correctly, be it port-forwarding or a setup like BungeeCord (I have no idea if it still exists or not due to being out of Minecraft for a while).

An even-more involved setup is to have someone work on your server's codebase, someone probably familar with the server codebase, to add the ability to listen to a "request" to update its cached queries... something that may have to be re-done each time you update the server's executable / .jar file.

Quick Edit: Most Minecraft servers are assumed to be running on a static IP or behind a firewall that is port-forwarded to it. If you suggest the idea as a feature request on a Mojang member's Twitter, you might get enough of an audience to have them implement the idea... probably have it as a in-config-file toggle / console command for the base game. This way, custom server coders don't need to re-implement the idea if they make it first.

  • Thank you, but restarting the server won't, help, the ip cached by minecraft is still the wrong one. I now use a static IP, but I have no way to change clear minecraft's cache. Maybe be reinstalling java ? Do you know a way to flush the dns cache of minecraft ? Or Java is maybe caching it as well...
    – tourdetour
    Dec 23 '16 at 20:07
  • I need to be able to update the dns because I have my server port forwarded to the net when I'm outside of home, with a dns SRV rule pointing to the server, let's say, www.example.com pointing to my modem. But when I want to access to my server from the inside of my local network, I query my local dns server for www.example.com and it acts as a proxy redirecting my request to the local ip of the server.
    – tourdetour
    Dec 23 '16 at 20:10
  • I am by no means super knowledged in these fields, I'll say that. I do know that if your computer that is in your network is set as static, port-forwarding is a piece of cake. Another thing to try is see if you can set any routers in your network to point so-and-so address directly to your server (I think the term is "manipulating the routing table"). Dec 23 '16 at 20:33
  • Also, when using DHCP, some routers allow reserving an IP address to a MAC address. Dec 23 '16 at 20:35
  • 1
    @tourdetour The only other option I can think of is having an entry in your game client's hosts file that gets set to an invalid address ( should work) by a script of some sort, whenever you start your device up, or wake it up from sleep / standby / hibernate. You could also, if you play it safe and never launch the game twice, change your launcher's shortcut to point to a script, prompting you where you want it (the fake address) to point to, do what it needs to (query correct DNS server, replacing the right entry in hosts file), and finally end up starting the launcher. Dec 30 '16 at 23:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.