From ruby-talk Wed Dec 06 11:33:12 2006 From: Rene Tschirley Date: Wed, 06 Dec 2006 11:33:12 +0000 To: ruby-talk Subject: Re: Starting XMLRPC server on virtual host returns EADDRNOTAVAIL Message-Id: <4576AA67.2090203 () tschirley ! com> X-MARC-Message: https://marc.info/?l=ruby-talk&m=116540490022850 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). [...] > 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. 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