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


We are currently running numerous soql queries via the rest api.


The issue we see is that sporadically throughout the day we will receive


"message"=>"Your query request was running for too long.", "errorCode"=>"QUERY_TIMEOUT"


errors.  The same queries will run fine at diffferent times during the day as well..


So my quesiton is what are the limits/timeout settings using the REST API.  In the documentation I don't see anything about how to set a time out or any limit settings, like we could do in the SOAP API..  We think it appears to be timing out around 1 minute.


Any help is appreciated..




Maximum timeout for all callouts (HTTP requests or Web services calls) in a request is120 seconds and default timeout of callouts (HTTP requests or Web services calls) in a request is 10 seconds.


So for ths you can make use of setTimeout method of HttpRequest Class ( It Sets the timeout in milliseconds for the request. This can be any value between 1 and 60,000 milliseconds).


Also it seems you are making a request that is to bulky (with number of records), so just try to make use of "Limit" clause in your SOQL query , this will help you to reduce the record size.



Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 


Thanks for the reply but I'm not sure this answers my question.


The information you provided is for when making "Call OUTs" to methods OUTSIDE of Salesforce.  We're using the REST API to "Call INTO" our salesforce org to execute a soql query..


To be specific we're using ruby and the REST query API to invoke some soql queries into our org from OUTSIDE of our org.  As a previously stated this works fine but we have issues with query timeouts sporadically throughout the day and we can't find any documentation in the API REST guide on what those governer limits are.


Thanks for any help you can provide.

Ben PovlichBen Povlich

Did you ever get any more information on this?  I'm currently also having issues with QUERY_TIMEOUT errors calling the REST API (using Ruby).






Unfortunately no..  We too are using Ruby => REST API and we get those query timeout errors for any SOQL query that runs longer than 1 minute which in our scenario can happen.. We used to run those queries directly in Apex and they worked (longer timeout goveror limit we guess)..


It's obvious the guy who tried to answer me before didn't understand my question and was repeating help document text to me..


It's a shame because this is another reason why we're using less and less of this SF architecture as possible in our application.


This might answer your question regarding what the limits/timeout settings are:


This is a quote from the 2007 version of the Salesforce SOAP API Reference (I found a copy here:

"Queries that take longer than two minutes to process will be timed out. For timed out queries, the ApexWeb service returnsanExceptionCodeof QUERY_TIMEOUT. If a timeout occurs, refactor your query to return or scan a smaller amount of data."


The newest SOAP API Reference has it worded differently (quoted from

"Queries that take longer than two minutes to process will be timed out. For timed out queries, the API returns an API fault element of InvalidQueryLocatorFault. If a timeout occurs, refactor your query to return or scan a smaller amount of data."




Thanks for the reply but unfortunately we're not using the SOAP interface but the REST one..  Which has no information on that same limit..  Like I said earlier i believe the limit to be 1 minute but was wondering if there's a way to configure this in the REST request somehow..

Any information here? I coudln't find this doucmented anywhere about the timeout for inbound REST API calls

Standard governor limits apply:

This is currently 120 seconds.

Praveen KHariPraveen KHari
Hi Everyone,

Do we have any solution for this. I have a native iOS app that use mobile SDK and gets same error for couple of SOQL query.

-Praveen K Hari