# Starting XMLRPC server on virtual host returns EADDRNOTAVAIL

**URL:** <https://www.ruby-forum.com/t/starting-xmlrpc-server-on-virtual-host-returns-eaddrnotavail/78380>\
**Category:** Ruby\
**Created:** [December 5, 2006, 12:50pm UTC](https://www.ruby-forum.com/t/starting-xmlrpc-server-on-virtual-host-returns-eaddrnotavail/78380 "2006-12-05T12:50:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rene\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6de8d8/32.png) [@Rene\_T](https://www.ruby-forum.com/u/Rene_T)\
**Post date:** [December 5, 2006, 12:50pm UTC](https://www.ruby-forum.com/t/starting-xmlrpc-server-on-virtual-host-returns-eaddrnotavail/78380/1 "2006-12-05T12:50:57Z")

</div>

Dear ruby experts,

I tried to start a Ruby XMLRPC server on a linux-based virtual host  
(using OpenVZ).

Here is the code:

$server = {  
“host” =\> “my.host.name”,  
“port” =\> 73726  
}

XMLRPC::Server.new(port=$server[‘port’],host=$server[‘host’])

While the code works on a non-virtual host, bind returns EADDRNOTAVAIL  
when the server is started on the virtual host:

[2006-12-05 11:35:24] INFO WEBrick 1.3.1  
[2006-12-05 11:35:24] INFO ruby 1.8.5 (2006-08-25) [i486-linux]  
[2006-12-05 11:35:24] WARN TCPServer Error: Cannot assign requested  
address - bind(2)  
/usr/lib/ruby/1.8/webrick/utils.rb:73:in `initialize': Cannot assign requested address - bind(2) (Errno::EADDRNOTAVAIL) from /usr/lib/ruby/1.8/webrick/utils.rb:73:in`new’  
from /usr/lib/ruby/1.8/webrick/utils.rb:73:in `create_listeners' from /usr/lib/ruby/1.8/webrick/utils.rb:70:in`each’  
from /usr/lib/ruby/1.8/webrick/utils.rb:70:in `create_listeners' from /usr/lib/ruby/1.8/webrick/server.rb:75:in`listen’  
from /usr/lib/ruby/1.8/webrick/server.rb:63:in `initialize' from /usr/lib/ruby/1.8/webrick/httpserver.rb:24:in`initialize’  
from /usr/lib/ruby/1.8/xmlrpc/server.rb:635:in `new' from /usr/lib/ruby/1.8/xmlrpc/server.rb:635:in`initialize’  
from /net/usr/lib/libversand.rb:53:in `new’

I tried to define the host by giving the numeric address. I checked that  
the host can resolve the hostname. The server can ping the server  
address. The above code is started as superuser. Linux kernel version is  
2.6.16, OpenVZ patch is version 026test015.

Any suggestions?

Thanks in advance,  
Rene

---

<div class="post-metadata">

**Author:** ![Rene\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6de8d8/32.png) [@Rene\_T](https://www.ruby-forum.com/u/Rene_T)\
**Post date:** [December 5, 2006, 1:04pm UTC](https://www.ruby-forum.com/t/starting-xmlrpc-server-on-virtual-host-returns-eaddrnotavail/78380/2 "2006-12-05T13:04:58Z")

</div>

> Here is the code:
> 
> $server = {  
> “host” =\> “my.host.name”,  
> “port” =\> 73726  
> }

Try a port number below 65536.

Caleb

---

<div class="post-metadata">

**Author:** ![Rene\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6de8d8/32.png) [@Rene\_T](https://www.ruby-forum.com/u/Rene_T)\
**Post date:** [December 5, 2006, 1:41pm UTC](https://www.ruby-forum.com/t/starting-xmlrpc-server-on-virtual-host-returns-eaddrnotavail/78380/3 "2006-12-05T13:41:02Z")

</div>

Caleb T. schrieb:

> Try a port number below 65536.

Sorry, I forgot to mention this: I tried to use other ports, too:  
reserved ports below 1023, and ports between 1024 and 64k. This all  
produces the same result (EADDRNOTAVAIL).

But anyway, thanks for your idea.

Rene

---

<div class="post-metadata">

**Author:** ![Rene\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6de8d8/32.png) [@Rene\_T](https://www.ruby-forum.com/u/Rene_T)\
**Post date:** [December 5, 2006, 2:29pm UTC](https://www.ruby-forum.com/t/starting-xmlrpc-server-on-virtual-host-returns-eaddrnotavail/78380/4 "2006-12-05T14:29:09Z")

</div>

2006/12/5, Rene T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> requested address - bind(2) (Errno::EADDRNOTAVAIL)
> 
> I tried to define the host by giving the numeric address. I checked that  
> the host can resolve the hostname. The server can ping the server  
> address. The above code is started as superuser. Linux kernel version is  
> 2.6.16, OpenVZ patch is version 026test015.

Have you tried instantiating server with:

XMLRPC::Server.new(port=$server[‘port’])

---

<div class="post-metadata">

**Author:** ![Rene\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6de8d8/32.png) [@Rene\_T](https://www.ruby-forum.com/u/Rene_T)\
**Post date:** [December 5, 2006, 9:00pm UTC](https://www.ruby-forum.com/t/starting-xmlrpc-server-on-virtual-host-returns-eaddrnotavail/78380/5 "2006-12-05T21:00:31Z")

</div>

On Dec 5, 2006, at 03:50 , Rene T. wrote:

> XMLRPC::Server.new(port=$server[‘port’],host=$server[‘host’])
> 
> I tried to define the host by giving the numeric address. I checked  
> that  
> the host can resolve the hostname. The server can ping the server  
> address. The above code is started as superuser. Linux kernel  
> version is  
> 2.6.16, OpenVZ patch is version 026test015.

For a WEBrick virtual host you need to pass :DoNotListen =\> true in  
the configuration options for the vhost WEBrick::HTTPServer:

httpd = WEBrick::HTTPServer.new :DocumentRoot =\> nil  
vhost = WEBrick::HTTPServer.new :DoNotListen =\> true,  
:ServerName =\> ‘[vhost.example.com](http://vhost.example.com)’,  
:DocumentRoot =\> nil  
httpd.virtual\_host vhost

I’m not sure how to do this with XMLRPC::Server, though.

–  
Eric H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)

I LIT YOUR GEM ON FIRE!

---

<div class="post-metadata">

**Author:** ![Rene\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6de8d8/32.png) [@Rene\_T](https://www.ruby-forum.com/u/Rene_T)\
**Post date:** [December 6, 2006, 11:02am UTC](https://www.ruby-forum.com/t/starting-xmlrpc-server-on-virtual-host-returns-eaddrnotavail/78380/6 "2006-12-06T11:02:58Z")

</div>

Michel C. write:

> Have you tried instantiating server with:
> 
> XMLRPC::Server.new(port=$server[‘port’])

Yes, I have tried this, too. Same result.

BTW: I forgot to mention the constructor’s third parameter. In fact, I  
call XMLRPC::Client.new(  
$bestellungsServer[‘host’],  
“/RPC2”,  
$bestellungsServer[‘port’]  
)

Rene

---

<div class="post-metadata">

**Author:** ![Rene\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6de8d8/32.png) [@Rene\_T](https://www.ruby-forum.com/u/Rene_T)\
**Post date:** [December 6, 2006, 11:14am UTC](https://www.ruby-forum.com/t/starting-xmlrpc-server-on-virtual-host-returns-eaddrnotavail/78380/7 "2006-12-06T11:14:59Z")

</div>

Hi!

Eric H. wrote:

> For a WEBrick virtual host you need to pass :DoNotListen =\> true in the  
> configuration options for the vhost WEBrick::HTTPServer:

I’m not very sure if I did get this right.

I did /not/ try to create a virtual XMLRPC server, analogue to a virtual  
HTTP server which presents itself as HTTP server which runs adjacent to  
an other server on the same host.

The virtual host which is ought to run the XMLRPC server is a virtual  
root server with its own OS. This is realised by OpenVZ on OS-level. It  
presents itself as a completely different machine.

Though I believe that the virtual host behaves /very/ similar to a  
non-virtual host, the problem is obviously related to the server’s  
virtuality.

Anyway, defining DoNotListen didn’t change anything. Thanks anyway!

Rene

---

<div class="post-metadata">

**Author:** ![Rene\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6de8d8/32.png) [@Rene\_T](https://www.ruby-forum.com/u/Rene_T)\
**Post date:** [December 6, 2006, 12:35pm UTC](https://www.ruby-forum.com/t/starting-xmlrpc-server-on-virtual-host-returns-eaddrnotavail/78380/8 "2006-12-06T12:35:14Z")

</div>

Hi all!

Thanks to you all who have meditated on my problem. I was able to solve  
it and for documentation purposes, I now present the solution.

Problem:

> I tried to start a Ruby XMLRPC server on a linux-based virtual host  
> (using OpenVZ).  
> […]  
> from /usr/lib/ruby/1.8/webrick/utils.rb:73:in `create\_listeners’  
> the host can resolve the hostname. The server can ping the server  
> address. The above code is started as superuser. Linux kernel version is  
> 2.6.16, OpenVZ patch is version 026test015.

Solution:

The kernel routing table on a plain VE looks like this:

Destination Gateway Genmask Iface  
191.255.255.1 \* 255.255.255.255 venet0  
default 191.255.255.1 0.0.0.0 venet0

The IP address 191.255.255.1 seems to be a OpenVZ-related special IP  
address which is used to route the client’s IP traffic to the host.

I changed these routes to match the intranet’s common values:

Destination Gateway Genmask Iface  
192.168.1.0 \* 255.255.255.0 venet0  
default 192.168.1.0 0.0.0.0 venet0

Now, the XMLRPC server is able to open the port. Somehow, the server  
wasn’t able to open the port with the other routing tables. Note that  
the interface venet0 was correctly set to listen to IP address  
192.168.1.n in both cases!

Rene
