Cannot reach external API with simple flask app

thuxen
TRIAL

7 months ago

Sorry if its a dumb question but im new and testing out railway.

I made a simple flask app to pull some data from the binance:
def getfundingrate():
url = 'https://fapi.binance.com/fapi/v1/fundingRate?symbol=BTCUSDT&limit=100'
response = requests.get(url)
if response.status_code == 200:
return response.json()
return None

Run locally its fine, but whenever i deploy to railway, it cannot communicate with the api, what do i need to do to communicate with an external api?

0 Replies

thuxen
TRIAL

7 months ago

Project ID: 98f82854-e5c9-41ce-95da-70487e296839


thuxen
TRIAL

7 months ago

yes, i added some simple code to ping the api:
@app.route('/section2/testapi') def testapi():
response = requests.get('https://api.binance.com/api/v3/ping')
if response.statuscode == 200: return "API is reachable", 200 else: return "Error reaching API", response.statuscode

When run locally i get this: API is reachable

When run on railway i get this: Error reaching API


7 months ago

binance is known to block GCP IP addresses, we run a large portion of workloads on GCP by default.

Please try switching to one of our two metal regions in your service settings.


thuxen
TRIAL

7 months ago

hmm ok unfortunately same issue with the two metal regions


7 months ago

what status code do you get


thuxen
TRIAL

7 months ago

451


7 months ago

that's not something we could help with unfortunately


Cannot reach external API with simple flask app - Railway Help Station