-1

I am developing an application in electronJS to run in Linux environment. It was working on old version of SLES15 SP4. When I upgraded the OS to SELES 15 SP5. I can see electron code is not able to call RES endpoint.

Description about issue:

  • Electron code is making REST call to endpoint http://localhost:8080/v1/myapp.

  • It seems localhost is mapped to ::1 ipv6 IP. Which is causing issue.

    Error log snippet: Error: connect ECONNREFUSED ::1:8082

  • content of /etc/hosts file:

    # cat /etc/hosts

    127.0.0.1 localhost

    ::1 localhost ipv6-localhost ipv6-loopback

  • Now My question is why localhost is mapping to ::1 and not to 127.0.0.1. while the same code was working fine in old version OS with same content in /etc/hosts file.

NOTE: If you will comment line ::1 localhost ipv6-localhost ipv6-loopback in /etc/hosts file it will start working. But my requirement is to make it work with same content in /etc/hosts file.

Rohit
  • 406
  • 1
  • 5
  • 21
  • (a) you could just be explicit and use `http://127.0.0.1:8080` instead of `http://localhost:8080`, or (b) you could fix your code so that it doesn't matter and both ipv4 and ipv6 connections will work. You would need to show us your code for us to help you with that option. – larsks Jul 24 '23 at 14:15

1 Answers1

0

The default is to resolve "names" to their IPv6 address, instead of IPv4 addresses. I'm sure this is the default since a while already.

The way how the glibc resolver works can be controlled via /etc/gai.conf, see the gai.conf(5) man page for details.

olh
  • 170
  • 10