JohnMerlino JohnMerlino - 2 months ago 9
Ruby Question

ruby cannot assign requested address

I had already created a qt program that listens on a specific port on my server. And it works fine. Now I want to create a simple ruby program to do the same. Right now I just have a simple test server using netcat which establishes a network socket and accepts UDP data (this is Ubuntu server by the way):

$ sudo nc -l 1720

Now I am just trying to listen on the port in Ruby:

# network.rb

require 'socket'

socket =
socket.bind('', 1720)

This right away raises this exception:

network.rb:4:in `bind': Cannot assign requested address - bind(2) (Errno::EADDRNOTAVAIL)

WHy is it saying the address is not available? All that is there is a netcat socket. The goal is that I will have UDP data coming in from GPRS devices to that port, and then I will have ruby sitting on my ubuntu server listening for that data, then decoding it, and storing it into a postgresql database.


You are making a server or client?

you used nc, so i guess you are making client.

server is bind

client is connect:

c =

c.connect("", 1111)

"address is not available" usually as the port is used.

or you can ping the address fisrt to check if the address can be reached