Matt Ball asked:
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.
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.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.