504 gateway timeout error

Hi everyone,

I’m facing an issue where the Asset API fails with a 504 Gateway Timeout. I found a previous discussion about the exact same problem, but the thread only states that it was “resolved” without explaining how. Unfortunately, the responses there don’t provide a clear solution.

A few key points about my situation:

My server utilization is very low, so resource exhaustion doesn’t seem to be the issue.

Only pages that interact with the Asset API are slow, while the rest of the system performs normally.

If you’ve encountered this before, how did you resolve it? Any insights or troubleshooting suggestions would be greatly appreciated!

Thanks in advance.

Hi @redet. For future reference… I moved you post to a new topic because following up on a 5-year old post, especially one that has been flagged a ‘solved’, may fly under the radar… So please open any new issues with a new topic.

Can you please provide a bit more info about your specific environment, specifically what server you are on, when exactly this occurred (so we might check associated log entries), etc.

attn @Kal_Lam

2 Likes

Welcome to the community, @redet! As requested by @Xiphware could you let us know he sever you are using? We would be happy to have a screenshot of your issue if it’s shareable,

It is a self-host instance using 2.024.36h. The issue is intermittent.

From the uwsgi.log file we found out that it was timing out while connecting to ee service.

ERROR 2025-03-31 09:10:54,054 openrosa_backend 158 140434739075008 Failed to retrieve links from Enketo
Traceback (most recent call last):
  File "/opt/venv/lib/python3.10/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/opt/venv/lib/python3.10/site-packages/urllib3/util/connection.py", line 95, in create_connection
    raise err
  File "/opt/venv/lib/python3.10/site-packages/urllib3/util/connection.py", line 85, in create_connection
    sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 715, in urlopen
    httplib_response = self._make_request(
  File "/opt/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 416, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/opt/venv/lib/python3.10/site-packages/urllib3/connection.py", line 244, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/local/lib/python3.10/http/client.py", line 1283, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.10/http/client.py", line 1329, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.10/http/client.py", line 1278, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.10/http/client.py", line 1038, in _send_output
    self.send(msg)
  File "/usr/local/lib/python3.10/http/client.py", line 976, in send
    self.connect()
  File "/opt/venv/lib/python3.10/site-packages/urllib3/connection.py", line 205, in connect
    conn = self._new_conn()
  File "/opt/venv/lib/python3.10/site-packages/urllib3/connection.py", line 179, in _new_conn
    raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPConnection object at 0x7fb95f9b0340>, 'Connection to ee.kobo.dhis.et timed out. (connect timeout=None)')

During the handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/venv/lib/python3.10/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
  File "/opt/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 799, in urlopen
    retries = retries.increment(
  File "/opt/venv/lib/python3.10/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='ee.kobo.dhis.et', port=80): Max retries exceeded with url: /api/v2/survey/all (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7fb95f9b0340>, 'Connection to ee.kobo.dhis.et timed out. (connect timeout=None)'))

The issue is visible only when we hit the asset API endpoint

http://kf.kobo.dhis.et/api/v2/assets/ai3gdTbZebcFrdQggvEkAS/?limit=100