I'm doing some code testing and one aspect is I need an active UDP Server. I've tried looking online how to install one and haven't had much luck.

My only requirement is a UDP Server which I can connect to with my code and retrieve a simple response.

I'm using Ubuntu 16.04 Xenial.

Can someone please assist in this.

My quesiton is to provide a UDP Server i can use.

I see Arcserve UDP Agent (Linux) but not sure because that might be for backups

I also see netcat but how do i send a response? Thanks!


Here is what Ive tried:

root@ubuntuT:/home/jon/gocode/udpserv# echo "pingpong" | nc -u -l 12345 &
[5] 36067
root@ubuntuT:/home/jon/gocode/udpserv# curl
curl: (7) Failed to connect to port 12345: Connection refused
  • Why downvote? I think its pretty clear.
    – somejkuser
    Jun 11, 2018 at 16:48
  • I added a question
    – somejkuser
    Jun 11, 2018 at 16:48
  • Curl is HTTP client. HTTP works on TCP protocol. So, trying to test UDP with HTTP client makes no sense. You need to use application that connects via UDP. Jun 11, 2018 at 17:12
  • Ups can create a simple UDP listener with netcat-u -l portnumber
    – HBruijn
    Jun 11, 2018 at 17:25

2 Answers 2


Try netcat:

nc -u -l 12345 < /dev/zero

It will start simple server that will send you zero-valued bytes on port 12345.


echo "pingpong" | nc -u -l 12345

if you want simple text answer.


You could install dnsmasq to listen on port 53/udp. That is a quick one.

You could start up a python listener on udp.

 #Python UDP Listener, listening on localhost 1025, change address 
 # to listen on other ip/port combos. 
 import socket

 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
 sock.bind(('', 1025))

 while True:
    data, address = sock.recvfrom(65538)
    text = data.decode('ascii')
    print('Connection from Client{} says {}'.format(address, text))
    text = 'Your data was {} bytes long'.format(len(data))
    data = text.encode('ascii')
    sock.sendto(data, address)

If you need a client this would work.

#UDP Client

import socket

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
text = 'Hello World'
data = text.encode('ascii')
sock.sendto(data, ('', 1025))
data, address = sock.recvfrom(65538) 

#text = data.decode('ascii')
#print('The server {} replied {}'.format(address, text))

You must log in to answer this question.

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