Lately I am hooked to WSL and have been using bash as my main terminal. It has auto complete, allows me to connect to my Raspberry PI and it just feels nice. However, I recently hit an issue where in I was not able to run any npm commands in zsh shell. Every time I ran any npm command I received error saying getaddrinfo EAI_AGAIN registry.npmjs.org. In this short post, I would like to show how I solved it.

Quick Google search and it was apparent that bash shell was not able to connect to the Internet. Scanning through the results, I found a link to WSL documentation and some common issues list.

Although none were actually resolutions to fix the specific error I was having, I decided to check my DNS setting for the zsh. So I ran cat command and to my surprise DNS entries were not right. Especially it was interesting to see that this (resolv.conf) file is autogenerated, so not sure if it was changed when I switched from bash to zsh.

> cat /etc/resolv.conf
# This file was automatically generated by WSL..
nameserver xxx.xxx.xxx.xxx

I altered the file (after taking backup) with correct DNS entries.

> sudo nano /etc/resolv.conf

Save and restarted the WSL, and boom! the npm command was working!

That is it, a quick post on how I solved the EAI_AGAIN error in WSL and a reminder to myself that I should check resolv.conf before blaming npm, oh-my-zsh or the WSL 🙏🏼.


Related Posts
About author
Utkarsh Shigihalli
Utkarsh Shigihalli
Utkarsh is passionate about software development and has experience in the areas of Azure, Azure DevOps, C# and TypeScript. Over the years he has worked as an architect, independent consultant and manager in many countries including India, United States, Netherlands and United Kingdom. He is a Microsoft MVP and has developed numerous extensions for Visual Studio, Visual Studio Code and Azure DevOps.
We Are
  • onlyutkarsh
    Utkarsh Shigihalli
    Microsoft MVP, Technologist & DevOps Coach


  • arora_tarun
    Tarun Arora
    Microsoft MVP, Author & DevOps Coach at Avanade

Do you like our posts? Subscribe to our newsletter!
Our Book