Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

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.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.