Elastic Transport for Python
raw JSON → 9.2.1 verified Tue May 12 auth: no python install: verified quickstart: stale
Elastic Transport for Python provides transport classes and utilities shared among various Python Elastic client libraries. It serves as a low-level HTTP client, powering the official Elasticsearch Python client and other Elastic projects. The library is currently at version 9.2.1 and follows a release cadence aligned with the major and minor versions of the Elastic Stack, with patch numbers incremented for bug fixes within a minor release.
pip install elastic-transport Common errors
error elastic_transport.ConnectionError: Connection error caused by: ConnectionError('Connection refused') ↓
cause This error indicates that the Python client could not establish a connection with the Elasticsearch server, often because the server is not running, is inaccessible due to a firewall, or the host/port configuration is incorrect.
fix
Ensure the Elasticsearch service is running, verify the host and port in your client configuration match the Elasticsearch server's settings (default HTTP port is 9200), and check for any firewall rules blocking the connection. For Docker environments, ensure containers can communicate using service names instead of 'localhost'.
error elastic_transport.TransportError: Transport error ↓
cause This is a generic exception from the 'elastic-transport' package, signaling a problem that occurred before an HTTP response was received. It can be caused by various underlying issues, including network connectivity problems, an unresponsive Elasticsearch server, or an invalid request body.
fix
Examine the full traceback and associated messages for more specific clues. Common resolutions include checking network stability, ensuring the Elasticsearch server is healthy and not overloaded, verifying that request bodies are not empty or malformed, and inspecting Elasticsearch logs for server-side errors.
error ModuleNotFoundError: No module named 'elastic_transport' ↓
cause This error means the Python interpreter cannot find the 'elastic_transport' package, usually because it has not been installed, or the current Python environment differs from where the package was installed.
fix
Install the package using pip:
python -m pip install elastic-transport. If already installed, ensure you are running your script within the correct Python virtual environment where elastic-transport was installed. error elastic_transport.TlsError: TLS error caused by: SSLError([SSL: WRONG_VERSION_NUMBER] wrong version number) ↓
cause This error typically occurs when the client attempts to connect using the wrong protocol (e.g., HTTPS client trying to connect to an HTTP server, or vice-versa) or there's a mismatch in SSL/TLS versions or certificates.
fix
Verify that the
scheme in your client configuration ('http' or 'https') matches the Elasticsearch server's configuration. If using HTTPS, ensure the server's SSL certificate is correctly configured and trusted by the client, and that the TLS versions are compatible. Warnings
breaking Python 3.8 and 3.9 support was removed in version 9.2.0. Python 3.7 support was dropped in 8.15.0. ↓
fix Upgrade to Python 3.10 or newer.
breaking The exception hierarchy changed significantly in version 8.x. `TransportError` now only covers transport-level errors (e.g., connection timeouts), while `ApiError` must be used for API-specific errors (e.g., index not found). ↓
fix Update exception handling logic to catch `ApiError` for errors originating from the Elasticsearch API.
gotcha When using `HttpxAsyncHttpNode`, 404 responses no longer raise exceptions by default; instead, the response with status 404 is returned. This changes the expected error handling behavior for 'not found' scenarios. ↓
fix Explicitly check the `meta.status` (HTTP status code) of the response for 404s if you need to treat them as errors.
gotcha Ensure compatibility with `httpx` by installing `httpx v0.28.0+` if using the `httpx` backend. Older versions may cause compatibility issues. ↓
fix Upgrade your `httpx` dependency to `v0.28.0` or higher if you use `elastic-transport[httpx]`.
gotcha The `urllib3` library is the default HTTP client backend. To use `requests`, `aiohttp`, or `httpx`, you must install the respective extra dependencies (e.g., `elastic-transport[requests]`) and explicitly pass the corresponding `NodeConfig` or `node_class` to the `Transport` constructor. ↓
fix Install the desired HTTP client extra and configure the `Transport` accordingly, e.g., `Transport(node_configs=[NodeConfig('...', http_compress=True)], node_class=RequestsHttpNode)`.
breaking The NodeConfig constructor signature changed from accepting a full URL string to requiring separate 'scheme', 'host', and 'port' arguments. ↓
fix Instantiate NodeConfig with explicit keyword arguments for scheme, host, and port, e.g., `NodeConfig(scheme='http', host='localhost', port=9200)`.
breaking The NodeConfig constructor expects separate 'host' and 'port' arguments, not a single URL string. Passing a full URL string as the first argument will result in a TypeError. ↓
fix Initialize NodeConfig with separate 'host' and 'port' arguments, for example, use NodeConfig('localhost', 9200, scheme='http') for the URL 'http://localhost:9200'.
Install
pip install elastic-transport[requests] pip install elastic-transport[aiohttp] pip install elastic-transport[httpx] Install compatibility verified last tested: 2026-05-12
python os / libc variant status wheel install import disk
3.10 alpine (musl) elastic-transport wheel - 0.33s 19.5M
3.10 alpine (musl) aiohttp wheel - 0.32s 19.5M
3.10 alpine (musl) httpx wheel - 0.32s 19.5M
3.10 alpine (musl) requests wheel - 0.33s 19.5M
3.10 alpine (musl) elastic-transport - - 0.34s 19.5M
3.10 alpine (musl) aiohttp - - 0.33s 19.5M
3.10 alpine (musl) httpx - - 0.33s 19.5M
3.10 alpine (musl) requests - - 0.33s 19.5M
3.10 slim (glibc) elastic-transport wheel 1.9s 0.23s 20M
3.10 slim (glibc) aiohttp wheel 1.7s 0.24s 20M
3.10 slim (glibc) httpx wheel 1.7s 0.23s 20M
3.10 slim (glibc) requests wheel 1.7s 0.23s 20M
3.10 slim (glibc) elastic-transport - - 0.24s 20M
3.10 slim (glibc) aiohttp - - 0.22s 20M
3.10 slim (glibc) httpx - - 0.23s 20M
3.10 slim (glibc) requests - - 0.22s 20M
3.11 alpine (musl) elastic-transport wheel - 0.44s 21.6M
3.11 alpine (musl) aiohttp wheel - 0.45s 21.6M
3.11 alpine (musl) httpx wheel - 0.48s 21.6M
3.11 alpine (musl) requests wheel - 0.47s 21.6M
3.11 alpine (musl) elastic-transport - - 0.52s 21.6M
3.11 alpine (musl) aiohttp - - 0.85s 21.6M
3.11 alpine (musl) httpx - - 0.51s 21.6M
3.11 alpine (musl) requests - - 0.52s 21.6M
3.11 slim (glibc) elastic-transport wheel 1.8s 0.40s 22M
3.11 slim (glibc) aiohttp wheel 1.8s 0.42s 22M
3.11 slim (glibc) httpx wheel 1.9s 0.40s 22M
3.11 slim (glibc) requests wheel 1.9s 0.44s 22M
3.11 slim (glibc) elastic-transport - - 0.39s 22M
3.11 slim (glibc) aiohttp - - 0.37s 22M
3.11 slim (glibc) httpx - - 0.39s 22M
3.11 slim (glibc) requests - - 0.39s 22M
3.12 alpine (musl) elastic-transport wheel - 0.63s 13.4M
3.12 alpine (musl) aiohttp wheel - 0.61s 13.4M
3.12 alpine (musl) httpx wheel - 0.63s 13.4M
3.12 alpine (musl) requests wheel - 0.63s 13.4M
3.12 alpine (musl) elastic-transport - - 0.66s 13.4M
3.12 alpine (musl) aiohttp - - 0.66s 13.4M
3.12 alpine (musl) httpx - - 0.65s 13.4M
3.12 alpine (musl) requests - - 0.66s 13.4M
3.12 slim (glibc) elastic-transport wheel 1.6s 0.56s 14M
3.12 slim (glibc) aiohttp wheel 1.7s 0.61s 14M
3.12 slim (glibc) httpx wheel 1.8s 0.59s 14M
3.12 slim (glibc) requests wheel 1.7s 0.60s 14M
3.12 slim (glibc) elastic-transport - - 0.59s 14M
3.12 slim (glibc) aiohttp - - 0.60s 14M
3.12 slim (glibc) httpx - - 0.60s 14M
3.12 slim (glibc) requests - - 0.60s 14M
3.13 alpine (musl) elastic-transport wheel - 0.62s 13.1M
3.13 alpine (musl) aiohttp wheel - 0.63s 13.1M
3.13 alpine (musl) httpx wheel - 0.60s 13.1M
3.13 alpine (musl) requests wheel - 0.65s 13.1M
3.13 alpine (musl) elastic-transport - - 0.61s 13.0M
3.13 alpine (musl) aiohttp - - 0.61s 13.0M
3.13 alpine (musl) httpx - - 0.63s 13.0M
3.13 alpine (musl) requests - - 0.63s 13.0M
3.13 slim (glibc) elastic-transport wheel 1.6s 0.55s 14M
3.13 slim (glibc) aiohttp wheel 1.7s 0.56s 14M
3.13 slim (glibc) httpx wheel 1.7s 0.55s 14M
3.13 slim (glibc) requests wheel 1.8s 0.61s 14M
3.13 slim (glibc) elastic-transport - - 0.58s 14M
3.13 slim (glibc) aiohttp - - 0.58s 14M
3.13 slim (glibc) httpx - - 0.60s 14M
3.13 slim (glibc) requests - - 0.59s 14M
3.9 alpine (musl) elastic-transport wheel - 0.29s 18.9M
3.9 alpine (musl) aiohttp wheel - 0.29s 18.9M
3.9 alpine (musl) httpx wheel - 0.29s 18.9M
3.9 alpine (musl) requests wheel - 0.29s 18.9M
3.9 alpine (musl) elastic-transport - - 0.29s 18.9M
3.9 alpine (musl) aiohttp - - 0.29s 18.9M
3.9 alpine (musl) httpx - - 0.31s 18.9M
3.9 alpine (musl) requests - - 0.29s 18.9M
3.9 slim (glibc) elastic-transport wheel 2.0s 0.26s 19M
3.9 slim (glibc) aiohttp wheel 2.0s 0.25s 19M
3.9 slim (glibc) httpx wheel 2.0s 0.26s 19M
3.9 slim (glibc) requests wheel 2.1s 0.27s 19M
3.9 slim (glibc) elastic-transport - - 0.25s 19M
3.9 slim (glibc) aiohttp - - 0.25s 19M
3.9 slim (glibc) httpx - - 0.25s 19M
3.9 slim (glibc) requests - - 0.26s 19M
Imports
- Transport
from elastic_transport import Transport - RequestsHttpNode
from elastic_transport import RequestsHttpNode - AiohttpHttpNode
from elastic_transport import AiohttpHttpNode - HttpxHttpNode
from elastic_transport import HttpxHttpNode - HttpxAsyncHttpNode
from elastic_transport import HttpxAsyncHttpNode - ApiError
from elastic_transport import ApiError - TransportError
from elastic_transport import TransportError
Quickstart stale last tested: 2026-04-24
import os
from elastic_transport import Transport, NodeConfig
# Configure nodes - replace with your Elasticsearch host(s)
# For local testing, default to 'http://localhost:9200'
# For cloud, use CLOUD_ID and API_KEY environment variables
cloud_id = os.environ.get('ELASTIC_CLOUD_ID', '')
api_key = os.environ.get('ELASTIC_API_KEY', '')
node_configs = [
NodeConfig("http://localhost:9200")
]
if cloud_id and api_key:
# Use Cloud ID and API Key for Elastic Cloud
transport = Transport(
node_configs=[], # node_configs are derived from cloud_id
cloud_id=cloud_id,
api_key=(api_key,)
)
else:
transport = Transport(node_configs=node_configs)
try:
# Perform a GET request to the root ('/') which often returns cluster info
# The response is a tuple of (ApiResponseMeta, deserialized_body)
meta, body = transport.perform_request("GET", "/")
print("Successfully connected to Elasticsearch!")
print(f"Cluster Name: {body.get('cluster_name')}")
print(f"Status Code: {meta.status}")
except Exception as e:
print(f"Failed to connect or perform request: {e}")
print("Ensure Elasticsearch is running and accessible at the specified host(s)")
print("Or check your ELASTIC_CLOUD_ID and ELASTIC_API_KEY environment variables.")
transport.close()