+ Start a Discussion

Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host


My problem is
Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in /***/soapclient/SforceBaseClient.php:113
Stack trace:
#0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'https://www.sal...', '', 1, 0)
#1 [internal function]: SoapClient->__call('login', Array)
#2 /***/soapclient/SforceBaseClient.php(113): SoapClient->login(Array)
#3 /***/test.php(7): SforceBaseClient->login('username@domain...', 'mypassword')
#4 {main} thrown in /***/soapclient/SforceBaseClient.php on line 113

Apache/1.3.37 (Unix)
PHP 5.2.1

cURL support  enabled 
cURL Information  libcurl/7.16.1 OpenSSL/0.9.7e zlib/1.2.3 

OpenSSL support  enabled 
OpenSSL Version  OpenSSL 0.9.7e-p1 25 Oct 2004 

Soap Client  enabled 
Soap Server  enabled 
soap.wsdl_cache 1
soap.wsdl_cache_dir /tmp
soap.wsdl_cache_enabled 1
soap.wsdl_cache_limit 5
soap.wsdl_cache_ttl 86400

allow_url_fopen = On

Same script is working from my local computer (apache 2.2, php 5.2.3 on windows) with exactly same settings.
I don't see any requirement about Apache version as long as PHP 5 works but it is the only difference beside windows - unix?

Thanks for helping!



As a followup to this message (I work with Suat),  we are testing the API connection from a shared hosting server, I am not sure this a good or bad idea.  Could the problem be with connection, with the shared server not allowing connection to salesforce API?

We are using with shared server as all our dedicated servers do not have PHP 5.1.4 (or later) which is required.  We are trying to solve this problem, but for now wanted to test with a shared server.

Any comments on this?   I am having the system admin allow connections to/from


Port 443.


Anything else?

I recognise this problem, same piece of code not working from server 1, but working perfectly when run on server 2. Not sure what the cause was though, havent been able to debug it (switched back to server 2;)). What error is being thrown in your case ?(looks like you didnt catch it here)

Message Edited by Harmpie on 07-02-2007 04:52 AM



I am getting the same error and I am kind of frustrated with this error. Because sometimes it gives me the error sometimes not.

2 days back I got the same error , after about 2 hrs , it started working fine. Now again I am having this error.

Please let me know if you know the error.



Tran ManTran Man
Is this still happening?  I have scripts that run all the time and have not seen this.

Could it be a problem somewhere between the host contacting the salesforce.com server?  I would try to replicate this outside of the context of the PHP toolkit possibly by just making a connection within a standalone PHP script.

Message Edited by Tran Man on 10-16-2007 06:12 PM


It is not happening now. Nothing changed in code, i think nothing changed on the server also.

I don't understand the issue here, it fails sometimes and sometimes works.

I do have code outside PHP toolkit and it was working fine at that time.

It must have someting to do with Host server or Salesforce Server. Yesterday I was having issues around 5 PM EST to around 9 PM EST.

This morning when i looked at it..it worked fine. I really need to resolve this because my applications which are live are affected and this intermittent issue is causing a lot of problems.

It is something to do with the server because all the applications where I am using Toolkit , I get the error.

Please help me here, Let me know if you need more information. The error is shown in the code that comes with the toolkit.


I just copied our integration to our linux server and am now seeing this error.  I have added our linux IP address to the Network Access area of our Salesforce account.  The exact same code works in our office on my windows machine I used for development.

Below is the SoapFault Exception:
[Errors] => SoapFault Object
    [message:protected] => Could not connect to host
    [string:private] => 
    [code:protected] => 0
    [file:protected] => /home/scale/public_html/test/core/salesforce/SforceBaseClient.php
    [line:protected] => 113
    [trace:private] => Array
    [faultstring] => Could not connect to host
    [faultcode] => HTTP
Note: I removed the full trace for privacy
Any ideas on this problem would be greatly appreciated.


Message Edited by sf_dave on 03-24-2008 11:48 AM

Message Edited by sf_dave on 03-24-2008 11:49 AM
Just a side note, my username is valid and I am using the password with the security token so that shouldn't be impacting this at all.

When I moved the code over on friday it was working just fine.  Today (Monday) when I came in it was throwing login exceptions consistantly.


Message Edited by sf_dave on 03-24-2008 12:12 PM
I have a client who just started experiencing this same issue with a PHP application that connects to Salesforce.com. I'm still trying to diagnose the issue, but I haven't been able to determine a reason why this would have started happening all of a sudden. Did any of you ever get a resolution to this issue?
I opened a ticket with Salesforce about this, but unfortunately (fortunately?) the problem just fixed itself...Salesforce didn't do anything :-|

It worked
then it didn't
then it did...???

Good luck trying to track it down....my connection refusal lasted about 2 days btw.

Sorry I couldn't provide any actual insight.

Thanks for the quick reply @sf_dave - same here, issue seemed to have resolved itself, but it was odd that Salesforce was unexplainedly refusing the connection for a while. I'll try to post more info if I can track anything down...

So if I understand, no one never understand why this error come's? and there is nobody from salesforce that have answered this thread?


Cause I have this for 2 days now and not resolving it, support said that it was outside their support boundaries and redirected me here, expecting that other user than them help or solve. Is this the final status of this issue with salesforces, since this is needed in order for us to start using salesforce?


Here's what i submited to salesforces:


 I'm using the correct enterprise.wsdl.xml with the simple exemple code that login with the SforceEnterpriseClient but I just cant connect to https://www.salesforce.com/services/Soap/c/16.0/0DF80000000Cr5S

This is the getLastRequest()
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:enterprise.soap.sforce.com"><SOAP-ENV:Body><ns1:login><ns1:username>acarpentier@mydomain.com</ns1:username><ns1:password>justhidingthisforthepost</ns1:password></ns1:login></SOAP-ENV:Body></SOAP-ENV:Envelope>

And this is the faultstring
Could not connect to host

One other thing I've tested is to connect on https://www.salesforce.com with curl and it's working fine...

Thanks for helping



I had this same issue: works on one server, but not the other.

The issue was resolved with openSSL support for PHP (not just cURL)


just recompile PHP with --with-openssl


Hope this helps,

Ben Carroll


I am having the same problem now for 6 months. I have always had both curl and openSSL installed for PHP.

I am joining the ranks of those with this intermintent error.  Sometimes it works, sometimes it doesn't. 

PHP, cURL, OpenSSL are all where they should be. (Heck, it works great half the time!)


Was there any resolution to this outside of the OpenSSL issue?


I'm seeing this in my log files about once a day, but I know other connections are working since new leads are showing up...


Very frustrating not to have any obvious way to debug this -- does Salesforce have anything that would let us know if they are having outages on their side?

Nick Van DusenNick Van Dusen

I'm also having this problem intermittently. Sometimes a script can go hours without issues; other times it happens within a few records. The fact that it bails on any further code execution is a huge problem for me, as I use the API to update our account info from an external database.


I am getting the problem intermittently - especially with long running scripts that make multiple calls to the server. It seems entirely random. The retry I have in place generally succeeds immediately following the error-generating call.


For example, I have a script that runs every 20 minutes, and updates SF with changes from our local database since the last update. Some days I get 30 of these errors, some days I get 10, some days 1 or 2.


I almost think they put it there on purpose to make sure we write decent error/exception handling code.  //smile//


I too am having this problem intermittently, however it seems to be more and more frequent recently.


It can happen either when logging into Salesforce API for the first time or on subsequent queries or inserts. For example a customer may be able to browse products from Salesforce them, complete an order and everything works correctly except occasionally one of the insert queries to write order information back will fail and the customer is left with the impression that the order failed, and only some insert queries are executed successfully.


This also happens with batch scripts that sync our databases each day and if the error is encountered the entire script is aborted.


We exception handle but not in a way that re-executes the query. Did anybody have any success with this?


We have about 5 clients integrating with Salesforce and all of them are experiencing this problem.


I am also facing same issue. But I guess that this issue is NOT on SF side.




When I use APEX data loader to call API 10 k times it worked properly without error.



a) May be : there is something wrong or something missing with our code which they have done while developing apex data loader

b) May be : APEX data loader has mechanism to handle exception and then re-try with same request if exception is like "Could not connect to host"


Still I don’t know what is going wrong. Anyone have solved this problem successfully please comment?


Thank you,



David DengDavid Deng

We had the similar problem yesterday:

we wrote cron job that downloads data from SF and uploads data to SF every day.  our cron job is written in PHP & Salesforce PHP Soap API, it has been working for a couple of years. All the sudden it stopped working yesrday and kept getting the error "Could not connect to host".


our cron job script is hosted on our production server that is managed by our ISP, the funny thing is that cron job works on our local server withut any errors.


We spent hours trying to figure out what the problem was on the production server.

1. Firstly we tried to add our production server's IPs (muliple IPs) to our SF's "Network Access" list in the Security Settings section, then tried the cron job script and it sometimes worked and othertime didn't work.  really frustrating.


2. We called our ISP and they told us a linux command to trace the network connections when running cron job script:


>strace YOUR_CRON_JOB_SCRIPT   2>&1 | grep -i connect

connect(4, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("")}, 16) = 0
connect(4, {sa_family=AF_INET, sin_port=htons(443), sin_addr=inet_addr("")}, 16) = -1 EINPROGRESS (Operation now in progress)
write(1, "Exception:\nCould not connect to "..., 36Exception:
Could not connect to host) = 36
Could not connect to host) = 58
write(1, "Could not connect to host", 25Could not connect to host) = 25
write(1, "Could not connect to host", 25Could not connect to host) = 25



the info above told us that the cron job script could not connect to SF's Soap API server on port 443, then we called SF support and didn't get much help from them.


3. We tried to connect to on a different server B which is in the same local network as our proudction server using this command:


> nc -z -w10 443

and it conneced to the successfully, then we called our ISP again asking for swapping the IP for our production server & server B.


Guess what?  our ISP then checked the firewall of the our production server and found that was in the Firewall block list, they removed this IP from the Firewall block list and everything started working again!


Hope this can help someone having the similar problems.




David Deng







Diego MachadoDiego Machado
I had the same problem today.
It seems to be related to the peer verification. I solved it by adding the following line to the options passed as the second parameter to SoapClient
$client = new SoapClient(null, array('location' => $soap_location,
'uri' => $soap_uri,
'trace' => 1,
'stream_context'=> stream_context_create(array('ssl'=> array('verify_peer'=>false,'verify_peer_name'=>false)))