question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The resolver does not re-read /etc/hosts upon change

See original GitHub issue

Expected behavior

When /etc/hosts is changed, the netty resolver should re-read it.

Actual behavior

io.netty.resolver.DefaultHostsFileEntriesResolver parses /etc/hosts only once, upon creation.

Netty version

4.1.67

JVM version (e.g. java -version)

any

OS version (e.g. uname -a)

any

The WatchService (https://docs.oracle.com/javase/tutorial/essential/io/notification.html) can be used to monitor /etc/hosts and re-read it immediately after it is changed. The same Java API can be used in UnixResolverDnsServerAddressStreamProvider for re-reading /etc/resolv.conf. At the very least, /etc/hosts should be re-read every few minutes (like the current approach for /etc/resolv.conf).

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
normanmaurercommented, Dec 15, 2021

There is already a pending PR for this: https://github.com/netty/netty/pull/11922

1reaction
normanmaurercommented, Dec 9, 2021

@bric3 I think we should just re-read after X seconds.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to reload /etc/hosts after editing in Linux?
You can restart the mentioned service by entering the following command in the command terminal. Any other issues related to the hosts' file...
Read more >
After modifying /etc/hosts which service needs to be restarted?
For the most part etc/hosts changes should be recognized immediately. ... restart the DNS resolver it will pick up the newly-added/edited etc/hosts entries....
Read more >
dnsmasq doesn't automatically reload when entry is added to ...
The thing is that in my project, the hosts will be changed like a few times per minute. This will make dnsmasq restart...
Read more >
Why do changes to /etc/hosts take effect immediately?
It says: "When resolving a hostname, first read /etc/hosts file to lookup the hostname, if not found then run a DNS query, if...
Read more >
How do I refresh the hosts file on OS X? - Super User
You don't need to. Simply sudo vim /etc/hosts , change what you need to change and go on. Your changes will be applied...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found