Solution: Hosts file parsing error with erlang/elixir on Windows

If you’re encountering the following error:


2020-12-08 01:01:32.768000
args: ["c:/WINDOWS/System32/drivers/etc/hosts",1]
format: "inet_parse:~p:~p: erroneous line, SKIPPED~n"
label: {error_logger,info_msg}
inet_parse:"c:/WINDOWS/System32/drivers/etc/hosts":1: erroneous line, SKIPPED

when running iex --name alice on Windows, you’re not alone. Turns out, the file encoding has to be ASCII for the parsing to work. But some other application like Docker might access the hosts file and change it’s encoding to UTF-8. This usually doesn’t affect day-to-day usage but for some reason, Earlang’s inet_parse doesn’t like this. To solve the above error you have to change the encoding of the host file to ASCII. This can be easily done with a PowerShell Command.

Open a Powershell window with Admin privileges. And execute the following:

Get-Content -Path "C:\Windows\System32\drivers\etc\hosts" | Out-File -FilePath "C:\Windows\System32\drivers\etc\hosts" -Encoding ascii

This should solve the above issue. If this doesn’t help you, please make sure you’re hosts file isn’t corrupted in any other ways.

One thought on “Solution: Hosts file parsing error with erlang/elixir on Windows

Leave a Reply

Your email address will not be published. Required fields are marked *