To answer to myself as a reference if someone else also has similar issues.
Build issue seems to be related to the issues in Haskell networking library, that is used by stack build tool. Although downloading files work correctly using wget and curl, stack was not able to use DNS to resolve the IP addresses of some hosts used during the build.
Putting the following in my /etc/hosts solved the build problem for me on that box, and I was able to build hledger again.
Why it started happening suddenly, and why it was working before is a mystery, but it looks like Haskell still has a way to go.
Cheers,
Marko