Score:0

Turn off IPv6 resolution for particular URL only

co flag

I'm having an issue with registry.npmjs.org -- When I attempt to access it through the command line (e.g. implicitly by using the npm command, or when doing a ping registry.npmjs.org), the access fails with a EHOSTUNREACH or "Destination unreachable" error. However, if I attempt to access the site through my web browser (Firefox), there's no issue in connecting.

Some online searches indicated that the issue might be related to IPv6/IPv4. And that indeed looks to be the case. Using the developer console indicates that Firefox is connecting to the site with IPv4, and error messages indicate the command line applications are using IPv6 addresses. nslookup registry.npmjs.org indicates a number of both types of addresses, and using ping on the IP addresses directly confirms that pinging the IPv4 addresses works, but the IPv6 addresses are unreachable.

I would like to turn off IPv6 address resolution specifically for registry.npmjs.org (or probably the whole of *.npmjs.org). I don't (to my knowledge) have any issues with IPv6 with any other websites, so I do not want to turn off IPv6 globally.

All the help articles I've seen in my searching have been about either turning off IPv6 entirely, turning it off for a particular interface, or changing all sites to prefer IPv4. I'd prefer to avoid doing that, and have the change in settings apply to the resolution of npmjs.org addresses only. Is there a way that can be done?

Score:0
mg flag

You could put the hostname and (one of) its IPV4 address into /etc/hosts like this

104.16.27.34 registry.npmjs.org

But you would have to ensure that stays up to date, so this is more a hack than a real solution.

Btw, at least as of today their IPV6 seems to work perfectly fine

$ ping registry.npmjs.org
64 bytes from 2606:4700::6810:1e22 (2606:4700::6810:1e22): icmp_seq=1 ttl=58 time=10.8 ms
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.