function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
EricVlachEricVlach 

perl script -- SF login fails when run from browser, but NOT when run locally

perl script testLogin.cgi contains a SF login call, and nothing else. When run locally from the server, (perl ./testLogin.cgi) it logs in correctly, no errors.

When run from a browser (http://mysite/cgi/testLogin.cgi) I get the following error:

500 Can't connect to www.salesforce.com:443 (Bad hostname 'www.salesforce.com') at Local/Salesforce.pm line 55

My Local::Salesforce.pm has the same login() and get_client() as WWW::Salesforce. Line 55 of my script is equivalent to line 469 in WWW::Salesforce.pm. SF_PROXY is https://www.salesforce.com/services/Soap/u/8.0. Everything looks right to me, so why does the script barf when run from the browser?

Here is testLogin.cgi:
#!/usr/bin/perl
use Local::Salesforce;
use CGI::Carp qw(fatalsToBrowser); #sends error messages to browser

my $sf = Local::Salesforce -> login('username' => 'MYUSERNAME',
                                    'password' => 'MYPASSWORD');

exit 0;




EricVlachEricVlach
Holy moly, SELinux can be a royal pain sometimes. It's funny how posting to this discussion board gets my debugger brain in motion, and I end up finding the answer myself anyway. Thanks, discussion board!

SELinux policies were not allowing browser-run scripts to connect to a socket. Solution, (on Fedora Core 7)

SELinux Administration > Boolean > HTTPD Service >
Allow HTTPD scripts and modules to connect to the network