Unable to connect to data.alpaca.markets: Connection refused

Hi, I have been using alpaca SIP data for 3 months without issue. But starting today I got Connection refused. What’s the reason and how to recover from it?

This is a super scary problem… imagine you were trading stocks and suddenly lost all market data streams…

chill out, its likely something on your end

Still doesn’t work today. I emailed tech support team and the answer wasn’t helpful. Here is the error message:

requests.exceptions.ConnectionError: 
HTTPSConnectionPool(host='data.alpaca.markets', port=443): 
Max retries exceeded with url: /v2/stocks/quotes?symbols=EEX&limit=10000&start=2024-04-18&end=2024-04-18&feed=sip&sort=asc 
(Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f4b3ba61210>: Failed to establish a new connection: [Errno 111] Connection refused'))

@PatL You should be able to fetch quotes for EEX. I tried the url posted in the error and it worked fine

curl --location 'https://data.alpaca.markets/v2/stocks/quotes?symbols=EEX&limit=10000&start=2024-04-18&end=2024-04-18&feed=sip&sort=asc' \
--header 'APCA-API-KEY-ID: xxxxx' \
--header 'APCA-API-SECRET-KEY: xxxxx'

The response was

"quotes": {
    "EEX": [
        {
            "ap": 9.7,
            "as": 1,
            "ax": "T",
            "bp": 2.74,
            "bs": 1,
            "bx": "T",
            "c": [
                "R"
            ],
            "t": "2024-04-18T08:08:41.604728832Z",
            "z": "A"
        },

I would guess there is an issue with urllib3 package. Which SDK (if any) are you using? Ensure the SDK is the most up to date version. Perhaps re-install it.

Hi Dan, thank for the response.

Unfortunately the error persists no matter what method I used to retrieve data

  • python requests
  • alpaca-py with the latest version

the error is the same above.

I strongly believe this is because alpaca data server has banned me when I was backfilling data. Please help checking with IT admin, thank you. I lost data acess for two days can not able to trade anymore.

Thanks again.

@PatL Have you tried making a request with a tool such as Postman or Curl? That will at least show that your account or IP hasn’t been ‘blocked’ (which Alpaca doesn’t do but that may prove that so you can discount that as an issue).

Alpaca doesn’t limit the number of connections. The error seems to occur before there is any authentication which would be before the API keys are read so Alpaca doesn’t even know the account or user etc.

There may be a network issue? Try resetting your router if you are using a home router. You could also try using a phone as a hotspot and bypass your network completely. That would rule out a network issue.

Thanks for the suggestions. I think there must be some network issue. Using my home network I got connection refused but if I use my AWS EC2 instance everything looks great. So there are two possibilities:

  1. Alpaca’s firewall blocked my home ip address.
  2. My ISP (Xfinity) blocked me from accessing alpaca’s servers.

If you could confirm alpaca never does #1, I will call Xfinity to resolve it. Thank you.

Closing this as I noticed it was blocked by Xfinity due to suspecious activity. I now recovered the data access. Thank you Alpaca team & @Dan_Whitnable_Alpaca

@PatL Glad to hear you got this resolved.

Alpaca doesn’t permanently block IP addresses (though there are some dynamic measures which are enforced if a DOS attack or other behavior is suspected). I personally have found my home router to be a culprit and a simple reboot has fixed it. A very effective troubleshooting aid is to connect via a phone hotspot or, as you did here, connect with a cloud instance. In either case that isolates the issue to a network problem or not.

Hey i should pop in to tell you stock trades should be done on fiber i learned this a long time ago as a cmts will never give you above 30 mbps for your upload, i needed a 200mb symmetrical plan on fiber with altice / optimum

your problem is throttling from your isp