2

I just ran into an issue where a request made to localhost:8080 from curl was hitting a different server than the same request made from inside Node. lsof -i :8080 revealed that two processes were both binding onto the same port:

COMMAND   PID  USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
node    51961 mball   14u  IPv4 0xd980e0df7f175e13      0t0  TCP *:http-alt (LISTEN)
java    62704 mball  320u  IPv6 0xd980e0df7fe08643      0t0  TCP *:http-alt (LISTEN)

How is this possible? Were they binding onto different interfaces? Or was it the IPv4 vs 6?

If you're curious, node was hitting the other node process, curl was hitting the java process. The java process was started after the node process.

1 Answer 1

4

They may be the same port, but they are not the same address - or even the same address family! Yes, the IPv4 versus IPv6 matters.

To fix the problem, have the desired process bind to both IPv4 and IPv6 address families.

7
  • Thanks. So do IPv4 and v6 each have their own separate set of ports?
    – Matt Ball
    Nov 7, 2013 at 2:51
  • They are utterly separate and have no influence on each other. Nov 7, 2013 at 2:52
  • When curl requests localhost, how does it know which type of request to make?
    – Matt Ball
    Nov 7, 2013 at 2:53
  • That's a totally different question. And I'm sure it's been answered somewhere on the SE network. Nov 7, 2013 at 2:55
  • 1
    Aha, I finally found it. How do client applications know to use IPv4 or IPv6? Nov 7, 2013 at 4:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .