Sam Sam - 8 months ago 60
Node.js Question

Node.js DGRAM module: Cannot send UDP message to remote machine but can to local machine

I am running a simple UDP server using Nodejs's dgram module.
Relevant code is simply:

server = dgram.createSocket('udp4');

When I netstat on the local machine, using this:

sudo netstat -l

I see this entry:

Proto Recv-Q Send-Q Local Address Foreign Address State
udp 0 0 localhost:10022 *:*

When I do a nmap from a remote machine using the IP address of the interface:

sudo nmap -sU -p 10022

I see this:

Nmap scan report for
Host is up (0.00032s latency).
10022/udp closed unknown

I have UDP client code running on the same machine which works fine when I use server.bind(10022,''), as done above. It does not when I use the real IP address assigned to the interface.

I also want to use the client code from a remote machine. So, when I use server.bind(10022, '') in place of server.bind(10022,''), I would have expected to be able to send messages to the UDP process from a remote machine. I cannot. Interestingly the send function's callback, in the remote machine, does not return an error either.

How do I get the client code on the remote machine send message to the UDP server. All firewalls were shutdown for testing because I initially suspected it to be a firewall issue. In any event, both the machines are on a local intranet during testing.


The address parameter of bind() is optional, you can try to listen to all local addresses ( by omitting it but still specify the port. Eg:


Regarding the missing error UDP is by default a not reliable protocol, the transmission will be treated as successful when it's sent on the wire. UDP does not send back and acknowledgement packet, if you need a reliable channel you can use TCP.