Cannot reach external API with simple flask app
thuxen
TRIALOP

2 years 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 get_funding_rate():

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?

Closed

7 Replies

thuxen
TRIALOP

2 years ago

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


thuxen
TRIALOP

2 years ago

yes, i added some simple code to ping the api:

@app.route('/section2/test_api')

def test_api():

response = requests.get('https://api.binance.com/api/v3/ping')

if response.status_code == 200:

return "API is reachable", 200

else:

return "Error reaching API", response.status_code

When run locally i get this: API is reachable

When run on railway i get this: Error reaching API


2 years 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
TRIALOP

2 years ago

hmm ok unfortunately same issue with the two metal regions


2 years ago

what status code do you get


thuxen
TRIALOP

2 years ago

451


2 years ago

that's not something we could help with unfortunately


Welcome!

Sign in to your Railway account to join the conversation.

Loading...