getredash/redash · error · Exception
Connection refused
Error message
Connection refused
What it means
Raised by the legacy ElasticSearch/Kibana query runner's test_connection when a requests.exceptions.RequestException occurs — i.e. the HTTP request never completed (DNS failure, refused socket, timeout, SSL error). It maps every low-level transport failure to the generic message 'Connection refused', which can be misleading (e.g. a timeout also produces it).
Source
Thrown at redash/query_runner/elasticsearch.py:333
add_column_if_needed(mappings, column, column, result_columns, result_columns_index)
value = h[column_name][column]
row[column] = value[0] if isinstance(value, list) and len(value) == 1 else value
result_rows.append(row)
else:
raise Exception("Redash failed to parse the results it got from Elasticsearch.")
def test_connection(self):
try:
r = requests.get("{0}/_cluster/health".format(self.server_url), auth=self.auth)
r.raise_for_status()
except requests.HTTPError as e:
logger.exception(e)
raise Exception("Failed to execute query. Return Code: {0} Reason: {1}".format(r.status_code, r.text))
except requests.exceptions.RequestException as e:
logger.exception(e)
raise Exception("Connection refused")
class Kibana(BaseElasticSearch):
@classmethod
def enabled(cls):
return True
def _execute_simple_query(self, url, auth, _from, mappings, result_fields, result_columns, result_rows):
url += "&from={0}".format(_from)
r = requests.get(url, auth=self.auth)
r.raise_for_status()
raw_result = r.json()
self._parse_results(mappings, result_fields, raw_result, result_columns, result_rows)
total = raw_result["hits"]["total"]
result_size = len(raw_result["hits"]["hits"])View on GitHub (pinned to ca79fe988d)
Solutions
- Verify the Elasticsearch/Kibana server URL and port (default 9200/5601) in the data source configuration and that the server is running
- Test reachability from the Redash host: curl -v <url> or telnet host port; check firewall/security groups
- If the server uses HTTPS or a self-signed cert, correct the URL scheme and certificate settings
- Prefer the elasticsearch2 query runner (newer) which gives more precise errors
Example fix
// before url = "http://es.example.com:9200" // after url = "https://es.example.com:9200" # correct scheme/port verified with curl
Defensive patterns
Strategy: validation
Validate before calling
import socket
url_host, url_port = "es.example.com", 9200
s = socket.socket()
s.settimeout(3)
try:
s.connect((url_host, url_port))
reachable = True
except OSError:
reachable = False
finally:
s.close() Try / catch
try:
runner.test_connection()
except Exception as e:
if str(e) == "Connection refused":
# transport-level failure: check URL/port/TLS, not the query
log_and_alert_network_issue(datasource_url)
else:
raise Prevention
- Verify host/port with curl or telnet before saving the data source
- Prefer the elasticsearch2 runner for clearer error messages
- Monitor Elasticsearch availability from the Redash host
When it happens
Trigger: Calling test_connection against an Elasticsearch/Kibana URL whose host/port is unreachable, wrong port, firewall blocking the connection, bad hostname, or HTTPS/SSL mismatch. Any RequestException that is not an HTTPError triggers it.
Common situations: Wrong URL/port in the Redash data source settings, Elasticsearch behind a proxy or requiring TLS, cluster down during setup verification, typo in host name.
Understand the failure class
- Connection failures: ECONNREFUSED, ECONNRESET, and friends — why connections get refused, reset, or dropped.
Related errors
- InfluxDB is not healthy. Check logs for more information.
- Username and Password required
- Azure AD Client ID, Client Secret, and Tenant ID are require
- Connection error to: {} {}.
- Couchbase connection error
AI-assisted analysis of getredash/redash@ca79fe988d (2026-08-28).
Data as JSON: /api/errors/6446847120d08cfb.
Report an issue: GitHub.