How to enable fsockopen()

The fsockopen() php command is supported on all of our shared and reseller servers, along with most of our VPS and Dedicated servers too. The purpose of this command is to open an outbound connection via a specific port to an external server. A common issue with using this command is the firewall on your server may not be configured to allow the connection that you are trying to make, please see below for explanations if you are getting errors on your site.

Common errors:

  • Warning: fsockopen() [function.fsockopen]: unable to connect to www.domain.com:8080 (Connection refused) in /home/cpuser/public_html/fsock.php on line 2
    Connection refused (111)
  • This error normally means that the connection is being blocked either on your server's side (outbound) or on the receiving server's side (inbound). If you are getting this error please come into live chat, email support@hostgator.com, or call us. We will be able to determine if the error is being generated by your server or on the remote server. Please see our article on opening new ports.
  • Warning: fsockopen() [function.fsockopen]: unable to connect to www.domain.com:8080 (Connection timed out) in /home/cpuser/public_html/fsock.php on line 2
    Connection timed out (110)
  • This error means that the connection timed out while it was being made. This can be cause by several reasons, however normally it means the remote server is not responding. An easy way to check this is by going to the URL in your browser to see if it works directly, such as http://www.domain.com:8080. If it loads there could be other connection issues, please contact our support and we will be glad to look into it further for you.