I forgot to tell that I can reproduce this only on some machines but not in others. The machines on which it fails (there are more than one) seem to be the ones having some corporate firewall rules I can't disable. This is probably not just a coincidence.
However, since packages are not supposed to use the network during the build, a bad network configuration should never make the package to FTBFS anyway. Thanks.