Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi everybody! I bumped into a new problem trying to make my scripts work under Unix (written and works for Windows) I have a simple script which by the means of URI::fetch parses rss feeds. Well it works on Windows in Explorer ok and in Unix it runs fine via terminal but while running via Mozilla i get empty screen and bad hostname 'news.google.com' in error log. The whole link i am using is "http://news.google.com/?ned=us&topic=t" I believe it has to do with HosnameLookups in Apache conf file but i changed it from "off" till "on" and it still doesnt work. Grateful for all advices, Alexander

Replies are listed 'Best First'.
Re: hostnamelookups in apache?
by ikegami (Patriarch) on Oct 11, 2006 at 21:31 UTC

    Why do you think HostnameLookups is involved? HostnameLookups determines whether Apache tries to get the domain name associated with an IP address for logging purposes (etc). The error message indicates the inability to do the opposite. It sounds like a dns lookup failure.

    >perl -MLWP::Simple -e "getprint 'http://bad.domain.com/'" 500 Can't connect to bad.domain.com:80 (Bad hostname 'bad.domain.com') + <URL:http://bad.domain.com/>

    Are you able to resolve news.google.com from your server? Are you sure it's spelled properly? (Try retyping it from scratch.) Are you sure there's no extra spaces or linefeeds? (Try printing the length of the uri.)

      I see, I think the problem is within apache options because the dns name resolves fine and i get lots of output from my script (read from news.google.com) via terminal, when i run the script as root or apache user. Its when i run it via Mozilla when i get this error. /AL

        It would be weird for Apache to bar your script from accessing the DNS server. Hold back on guessing and try debugging.

Re: hostnamelookups in apache?
by shmem (Chancellor) on Oct 11, 2006 at 23:23 UTC
    On UNIX, you say... what UNIX? What apache environment?

    Is your apache chroot()ed? If yes, that might be due to a missing or bogus /etc/resolv.conf in the changed root.

    Tell us more about your setup - guessing is so error-prone...

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
      Hi, It is Feodora4 on WmWare Workstatin, it is builtin apache server 2.0.54 and built in perl 5.8.6, it has NAT ip with the same external ip as my windows main computer. I tried to run that one-line script, perl -MLWP::Simple -e "getprint 'http://news.google.com/news?ned=us&topic=b&output=rss'" and got 403 on both Win and Unix but on Windows my script runs fine in IE6. Thank you for trying to help guys, i appreciate that! /Alexander
        Fedora 4 uses selinux, which adds restrictions to what httpd processes can do. One of the big restrictions is on the creation of sockets.. which could be a problem when resolving news.google.com

        If this is the case then you can configure it to allow the blocked behaviour. I don't have any personal experience with this, perhaps someone else can offer further advice.

        I am downloading the fedora4 image for vmware now so I can experiment with this further - the topic comes up often enough here.

        I guess you mean VMware Workstation.
        got 403 on both Win and Unix

        how? running your script on the commandline? where? did the 403 error show up in a browser, the logs, inside a network sniffer?

        but on Windows my script runs fine in IE6.

        Doh! that one must have escaped me. They built a perl interpreter into IE6? Brilliant!

        Your unaccurate way to express your problems (speling negligence let aside) makes it very difficult to help you.

        • check your DNS setup
        • do some hostname lookups from the commandline in your VMware guest
        • as for SeLinux, turn that off for testing purposes (append selinux=off to the kernel line in the grub bootloader)

        --shmem

        _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                      /\_¯/(q    /
        ----------------------------  \__(m.====·.(_("always off the crowd"))."·
        ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
      Hi, Now it works! I used this option "httpd_can_network_connect boolean on" and it works :-) setsebool -P httpd_can_network_connect 1 Thanks everyone and especially imp :) /Alexander