Alpaca-py issues - Max retries exceeded / NewConnectionError

I just upgraded to alpaca-py and am trying to get historical crypto data using my broker api keys.

I can get one or two tickers but after that it just throws the max retry exception:

HTTPSConnectionPool(host=‘data.alpaca.markets’, port=443): Max retries exceeded with url: /v1beta2/crypto/bars?start=2019-11-12&end=2022-07-31&timeframe=1Day&symbols=BTC%2FUSD (Caused by NewConnectionError(‘<urllib3.connection.HTTPSConnection object at 0x4097e470a0>: Failed to establish a new connection: [Errno 110] Connection timed out’))

I don’t think im going over the 200 request per minute limit. (I proved this by waiting 2 minutes and making a single request).

I must be doing something wrong because if there was a problem with alpaca-py, im sure others would have complained by now. How can I figure out why Im getting an NewConnectionError?

Thanks,
Brett

I’m going to post a different question in the market data section. I think the issue is im trying to send api keys to not get rate limited, and im probably sending the wrong keys to the wrong url_override.

I was getting HTTPSConnectionPool errors a few days ago and started another thread for that. Mine was complaining about server not responding before timeout.

I was trying to retrieve positions and 1 minute bars. I have increased
APCA_RETRY_MAX and APCA_RETRY_WAIT to value of 5 and it seems to somewhat work for 1 minute bar retrieval. This morning it took over 70 retries at 5 second intervals to retrieve 1 minute candle for symbol “BJ”. That is an awful delay of almost 10 minutes before a successful response.

I’ve been getting a similar error, intermittently, but only in the past couple of days, when requesting option snapshots. Not sure if this is because this is a beta route or what.
"HTTPSConnectionPool(host='data.alpaca.markets', port=443): Max retries exceeded with url: /v1beta1/options/snapshots?symbols=TSLA260220C00417500%2CTSLA260220C00415000&limit=1000 (Caused by SSLError(SSLEOFError(8, '[SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1016)')))"

I am getting the same kind of errors from the last couple of days.

New York time: 2026-02-04 15:30

Traceback (most recent call last):
File “/Users//opt/anaconda3/envs/quant-bot/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 715, in urlopen
httplib_response = self._make_request(
File “/Users//opt/anaconda3/envs/quant-bot/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 404, in _make_request
self._validate_conn(conn)
File “/Users//opt/anaconda3/envs/quant-bot/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 1060, in _validate_conn
conn.connect()
File “/Users//opt/anaconda3/envs/quant-bot/lib/python3.9/site-packages/urllib3/connection.py”, line 419, in connect
self.sock = ssl_wrap_socket(
File “/Users//opt/anaconda3/envs/quant-bot/lib/python3.9/site-packages/urllib3/util/ssl_.py”, line 449, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File “/Users//opt/anaconda3/envs/quant-bot/lib/python3.9/site-packages/urllib3/util/ssl_.py”, line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File “/Users//opt/anaconda3/envs/quant-bot/lib/python3.9/ssl.py”, line 501, in wrap_socket
return self.sslsocket_class._create(
File “/Users//opt/anaconda3/envs/quant-bot/lib/python3.9/ssl.py”, line 1074, in _create
self.do_handshake()
File “/Users//opt/anaconda3/envs/quant-bot/lib/python3.9/ssl.py”, line 1343, in do_handshake
self._sslobj.do_handshake()
ssl.SSLZeroReturnError: TLS/SSL connection has been closed (EOF) (_ssl.c:1133)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/Users//opt/anaconda3/envs/quant-bot/lib/python3.9/site-packages/requests/adapters.py”, line 667, in send
resp = conn.urlopen(
File “/Users//opt/anaconda3/envs/quant-bot/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 801, in urlopen
retries = retries.increment(
File “/Users//opt/anaconda3/envs/quant-bot/lib/python3.9/site-packages/urllib3/util/retry.py”, line 594, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘data.alpaca.markets’, port=443): Max retries exceeded with url: /v2/stocks/SPY/bars?timeframe=1Min&adjustment=all&start=2026-02-02T08%3A00%3A00%2B00%3A00&end=2026-02-06T08%3A00%3A00%2B00%3A00 (Caused by SSLError(SSLZeroReturnError(6, ‘TLS/SSL connection has been closed (EOF) (_ssl.c:1133)’)))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/Users//Desktop/Untitled_Folder/superai_bot_mvp.py”, line 972, in
SuperAI_Trading_Bot()
File “/Users//Desktop/Untitled_Folder/superai_bot_mvp.py”, line 966, in SuperAI_Trading_Bot
on_message()
File “/Users//Desktop/Untitled_Folder/superai_bot_mvp.py”, line 862, in on_message
open_prices, high_prices, low_prices, close_prices, volume, buylesstime, selltime = prepare_data(
File “/Users//Desktop/Untitled_Folder/superai_bot_mvp.py”, line 645, in prepare_data
full_data = vbt.AlpacaData.download(asset, start=data_start, end=data_end,
File “/Users//opt/anaconda3/envs/quant-bot/lib/python3.9/site-packages/vectorbt/data/base.py”, line 584, in download
data[s] = cls.download_symbol(s, **_kwargs)
File “/Users//opt/anaconda3/envs/quant-bot/lib/python3.9/site-packages/vectorbt/data/custom.py”, line 894, in download_symbol
df = client.get_bars(
File “/Users//opt/anaconda3/envs/quant-bot/lib/python3.9/site-packages/alpaca_trade_api/rest.py”, line 735, in get_bars
bars = list(self.get_bars_iter(symbol,
File “/Users//opt/anaconda3/envs/quant-bot/lib/python3.9/site-packages/alpaca_trade_api/rest.py”, line 718, in get_bars_iter
for bar in bars:
File “/Users//opt/anaconda3/envs/quant-bot/lib/python3.9/site-packages/alpaca_trade_api/rest.py”, line 594, in _data_get
resp = self.data_get(path, data=data, feed=feed,
File “/Users//opt/anaconda3/envs/quant-bot/lib/python3.9/site-packages/alpaca_trade_api/rest.py”, line 274, in data_get
return self._request(
File “/Users//opt/anaconda3/envs/quant-bot/lib/python3.9/site-packages/alpaca_trade_api/rest.py”, line 222, in _request
return self._one_request(method, url, opts, retry)
File “/Users//opt/anaconda3/envs/quant-bot/lib/python3.9/site-packages/alpaca_trade_api/rest.py”, line 241, in _one_request
resp = self._session.request(method, url, **opts)
File “/Users//opt/anaconda3/envs/quant-bot/lib/python3.9/site-packages/requests/sessions.py”, line 589, in request
resp = self.send(prep, **send_kwargs)
File “/Users//opt/anaconda3/envs/quant-bot/lib/python3.9/site-packages/requests/sessions.py”, line 703, in send
r = adapter.send(request, **kwargs)
File “/Users//opt/anaconda3/envs/quant-bot/lib/python3.9/site-packages/requests/adapters.py”, line 698, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host=‘data.alpaca.markets’, port=443): Max retries exceeded with url: /v2/stocks/SPY/bars?timeframe=1Min&adjustment=all&start=2026-02-02T08%3A00%3A00%2B00%3A00&end=2026-02-06T08%3A00%3A00%2B00%3A00 (Caused by SSLError(SSLZeroReturnError(6, ‘TLS/SSL connection has been closed (EOF) (_ssl.c:1133)’)))"

I have integrated retry logic, which seems to work after waiting a few seconds (typically 20-40 seconds), but that is not good because it is affecting our trading process. Is there anyone that can get this fixed?

The Alpaca Engineering team identified the root cause of the “connection aborted. Connection reset error 104 connection reset by peer” errors as a bug in the ingress server code. A fix has been implemented as of around 12:00 EST today 2026-02-05.

If you are still receiving these errors please reply and include your IP address if possible.

Apologies for this issue.

Thanks for the update Dan