Bitbucket code search intermittently fails with java.net.SocketTimeoutException error

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Searching for code in Bitbucket intermittently times out withjava.net.SocketTimeoutException error

Environment

Bitbucket Server/Datacenter 6.10.2

Bundled or remote Elasticsearch instance

Diagnosis

During investigation the following entries are found in the application logs.

Application logs

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 2020-10-20 12:10:18,120 DEBUG [http-nio-7990-exec-96] testuser *QJFEUBx730x9226605x5 qnl1o3 127.0.0.1,127.0.0.1 "POST /rest/search/latest/search HTTP/1.0" c.a.b.i.s.s.DefaultSearchService [77562] Search query: { "bool": { "must": { "bool": { "should": [ { "match": { "content": { "query": "test", "operator": "and" } } }, { "match": { "path": { "query": "test", "operator": "and" ... 2020-10-20 12:10:23,140 ERROR [http-nio-7990-exec-96] testuser *QJFEUBx730x9226605x5 qnl1o3 127.0.0.1,127.0.0.1 "POST /rest/search/latest/search HTTP/1.0" c.a.b.i.s.search.rest.SearchResource Failed to process search request 'RestSearchRequest{entities={code=PagingInfo{start=0, limit=0}}, limits=Limits{primary=25, secondary=10}, query='project:~TEST_PROJ repo:testrepo test'}' - error: java.net.SocketTimeoutException 2020-10-20 12:10:23,141 DEBUG [http-nio-7990-exec-96] testuser *QJFEUBx730x9226605x5 qnl1o3 127.0.0.1,127.0.0.1 "POST /rest/search/latest/search HTTP/1.0" c.atlassian.bitbucket.search.timing Timing: Search request execution took 5.076 s [5076 ms] for query '~TEST_PROJ repo:testrepo test' 2020-10-20 12:10:23,144 ERROR [http-nio-7990-exec-96] testuser *QJFEUBx730x9226605x5 qnl1o3 127.0.0.1,127.0.0.1 "POST /rest/search/latest/search HTTP/1.0" c.a.s.i.r.e.DefaultUnhandledExceptionMapperHelper Unhandled exception while processing REST request: "POST /rest/search/latest/search HTTP/1.0" java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.net.SocketTimeoutException

Cause

Due to a slowness to produce results from Elasticsearch, the request took longer than Bitbucket was expecting and it timed out the request. By default, Bitbucket sets a 5 seconds time out for waiting results from Elasticsearch.

Solution

Increase the code search timeout:

  1. Edit <BITBUCKET_HOME>/shared/bitbucket.properties adding the following parameter:

    1 plugin.search.search.http.socket.timeout=10

    ℹ️ In this example we raised the timeout to 10 seconds. However this may vary accordingly to the size of your instance.

  2. Restart Bitbucket.

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.