Saturday, 28 June 2014

Forcing refresh of Hosts file in Windows / Filezilla

As part of my web dev work I use an Ubuntu VM. Sometimes I need to transfer over files from the host machine, which I do using FTP through Filezilla. However, the IP address assigned to my Ubuntu VM sometimes changes, which means updating the Hosts file on the host machine with the new IP for the VM.

This used to work quite nicely, but the past few months I'd found that I needed to restart my PC otherwise Filezilla would still try to connect to the old IP even after the hosts file had been updated the new IP address. However, I found today that this was not actually an issue with a Filezilla update as I had previously thought. Instead it seems that it is because I have moved the location of the hosts file, and symlinked C:\Windows\System32\drivers\etc\hosts to the new location.

It seems quite strange to me that the system would refresh the DNS immediately when the hosts file is directly edited, but not when it is symlinked to a file that is edited. Anyway, I found the solution to avoid having to restart the PC to refresh the hosts file / DNS: Simply open a command prompt, then run ipconfig /flushdns.

In other news:

No comments: