[Linux] What if /etc/hosts edits do not work as expected?

Today, I encountered a problem when the edits I made to ‘/etc/hosts’ file on a Linux box didn’t work as expected.

In the /etc/hosts file I added the following line, shaakunthala.com

And to test, issued the following command,

$ ping shaakunthala.com

And the result was,

PING shaakunthala.com ( 56(84) bytes of data.

That’s not the IP address I wanted to temporarily set it to. So I looked up the Internet and various sources gave me the following firsthand solution.

# /etc/init.d/nscd restart

Restart the name service cache daemon. Similar to the ‘ipconfig/flushdns’ thing you would do on a Windows box.

And it worked!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s