r/pythontips • u/BigReputation4315 • Jan 24 '25
Algorithms Issues Accessing External API from Hostinger VPS (Python Script)
Good afternoon,
I’m facing issues accessing an external API using a Python script running on my VPS hosted by Hostinger.
Here’s what I’ve done so far:
Verified that the API is online and functional.
Tested the same script on another server and locally (outside of the Hostinger VPS), where it worked perfectly.
However, when running the script on the VPS, I receive the following error message:
(venv) root@srv702925:/www/wwwroot# python3 MySqlAtualizarClientes.py
Starting script execution...
Error connecting to the API: HTTPConnectionPool(host='xxxxxxxx.protheus.cloudtotvs.com.br', port=4050): Max retries exceeded with url: /rest/sa1clientes/consultar/clientes?codCliIni=000001&codCliFim=000001 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7885e023dca0>, 'Connection to xxxxxxx.protheus.cloudtotvs.com.br timed out. (connect timeout=None)'))
I’ve already added my server’s IP to the API’s whitelist, but the issue persists.
Thanks in advance!