AFAICT this code has not changed in quite some time; so I'm not sure what's causing the change in behaviour that you are seeing.
Which provider are you using? It would be helpful to understand so we can see the full context.
Having a final attempt using gethostbyname might be a sensible improvement - from memory this might return 127.0.1.1 on quite a few of the Juju providers, but that's worth testing with to see.
AFAICT this code has not changed in quite some time; so I'm not sure what's causing the change in behaviour that you are seeing.
Which provider are you using? It would be helpful to understand so we can see the full context.
Having a final attempt using gethostbyname might be a sensible improvement - from memory this might return 127.0.1.1 on quite a few of the Juju providers, but that's worth testing with to see.