http://www.perlmonks.org?node_id=794968

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

I have been pulling my hair out for a couple of days trying to find out why my perl program on a remote server wasn't able to connect to my webserver's ip with a non-stadard port specified, such as:

code snippet: $response = $ua->post("https://123.321.123.321:4430/scripts/my_script. +cgi", [%parameters]);

The $response->content from this unsuccessful attempt was: 500 Can't connect to 123.321.123.321:4430 (connect: timeout)

So, I tried changing the port forwarding so the standard ports 443/80 are forwarded to my webserver and WAS SUCCESSFUL with no port specified:

code snippet: $response = $ua->post("https://123.321.123.321/scripts/my_script.cgi", + [%parameters]);

Now the interesting thing is that running the requesting program from my test machine (Windows) I was able to connect BOTH ways successfully, but from my "live" machine (ISP - Linux) I can only connect to the standard port 80 with no port specified in the url. So, can anyone tell me why this is the case? I did some searching online and found references to a bug in Linux and/or IO::Socket on Linux that may cause this problem, but it wasn't clear to me. Any further enlightenment would be great. I would really prefer to run the webserver to which I am connecting for this task behind ports 4430/8080, not ports 443/80.

Replies are listed 'Best First'.
Re: LWP connect timeout only occurs with a port specified
by Sewi (Friar) on Sep 13, 2009 at 08:48 UTC
    I guess that this is not a Perl problem. Here are some tests you should run:
    Try adding explicit :80 or :443 to the URL. Doesn't work? This really seems to be a Perl problem, contact LWP support/maintainer
    Try start a local TCP server on port 4430 and connect to 127.0.0.1:4430 on the ISP server. Doesn't work? Really strange, contact your ISP and ask for firewall or non-standard server configuration.
    Use telnet 123.321.123.321 4430 on the ISP server and look if you get a connection (no automatic reply is expected).Doesn't work? You clearly have a network issue with your ISP or did some blocking configuration on your server.
    All above worked? Try another target server and/or port for testing. I'll /msg you the URL of a private machine of mine which runs a httpd on 8080.Works? The server 123.321.123.321 doesn't like your ISP server. Get another ISP.
    Still no hint? Get someone to start a webserver on port 4430 on his ISP server and try this.Works: 123.321.123.321 doesn't like your ISP server.
    Doesn't work: You ISP doesn't like port 4430, get another port or ISP.

    Notice:
  • All the hints are hints not this-must-be-the-reason-things.
  • There may be still some really stange OS, Perl, protocol or lib issues which would make it really really hard to find.
  • Yes, I noticed that 123.321.123.321 is not a valid IP. I just reused your placeholder for the hints. :-)
Re: LWP connect timeout only occurs with a port specified
by Gangabass (Vicar) on Sep 13, 2009 at 07:34 UTC

    Do you have any firewall running on your "live" machine?