On F7 the selinux policy prevents cgi (perl) scripts from connecting to
I cannot see any6way to tune this so have no choice but to disable selinux,
which is not a perfect solution
setsebool -P httpd_can_network_connect_db=1
Will allow this.
Try install setroubleshoot, this would have told you this.