Cannot reach external API with simple flask app

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?
9 Replies
Percy
Percy4d ago
Project ID: 98f82854-e5c9-41ce-95da-70487e296839
deltree
deltreeOP4d ago
Project ID: 98f82854-e5c9-41ce-95da-70487e296839
Prosper
Prosper4d ago
I can't see any errors in your logs so far. Everything looks fine. So, can you provide more deets on what you mean by it can't communicate with an external api?
deltree
deltreeOP4d 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
Brody
Brody4d 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.
deltree
deltreeOP3d ago
hmm ok unfortunately same issue with the two metal regions
Brody
Brody3d ago
what status code do you get
deltree
deltreeOP3d ago
451
Brody
Brody3d ago
that's not something we could help with unfortunately
Want results from more Discord servers?
Add your server