Based on the symptoms that you have described, the most likely cause is that your Load balancer / WebServer is timing out the underlying TCP socket connection.
The following are some next steps you can try.
Followup with your load balancer / Webserver admin to check the TCP Connection timeout. Try to tune the SQL query by executing an explain plan and finding the associated cost to see if adding or modifying indexes can improve the query execution time. If SQL query is tuned and there are no options to improve the query execution time, then increase the TCP Connection timeout in Load balancer/Webserver to a higher value. The timeout value should be at least 20% above the max/worst SQL query execution times.