CyberPunkMetalHead / binance-trading-bot-new-coins

This Binance trading bot detects new coins as soon as they are listed on the Binance exchange and automatically places sell and buy orders. It comes with trailing stop loss and other features. If you like this project please consider donating via Brave.
MIT License
1.46k stars 269 forks source link

getaddrinfo failed #31

Open AnthoK91 opened 2 years ago

AnthoK91 commented 2 years ago

I am quite new to python so please forgive what could be an easy fix. Based in Australia if that makes a difference.

From my research, getaddrinfo is an error that occurs when you try to make an API call but a connection cannot be made. There seem to be a few causes:

A) intermittent internet issues (I have none) B) A proxy messing things up (which I do not use) C) Hosts driver in system32 has a definition mismatch (nothing defined in there for me)

I have no idea why this issue is being cause but is there any chance someone could help me with a workaround for this?

Thanks

`"C:\Users\antho\Virtualenv Environment\Scripts\python.exe" C:/Users/antho/PycharmProjects/binance-trading-bot-new-coins-5/main.py Traceback (most recent call last): File "C:\Users\antho\Virtualenv Environment\lib\site-packages\urllib3\connection.py", line 169, in _new_conn conn = connection.create_connection( File "C:\Users\antho\Virtualenv Environment\lib\site-packages\urllib3\util\connection.py", line 73, in create_connection for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): File "C:\Users\antho\AppData\Local\Programs\Python\Python39\lib\socket.py", line 954, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno 11001] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\antho\Virtualenv Environment\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen httplib_response = self._make_request( File "C:\Users\antho\Virtualenv Environment\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request self._validate_conn(conn) File "C:\Users\antho\Virtualenv Environment\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn conn.connect() File "C:\Users\antho\Virtualenv Environment\lib\site-packages\urllib3\connection.py", line 353, in connect conn = self._new_conn() File "C:\Users\antho\Virtualenv Environment\lib\site-packages\urllib3\connection.py", line 181, in _new_conn raise NewConnectionError( urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x0000022EDC0479A0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\antho\Virtualenv Environment\lib\site-packages\requests\adapters.py", line 439, in send resp = conn.urlopen( File "C:\Users\antho\Virtualenv Environment\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen retries = retries.increment( File "C:\Users\antho\Virtualenv Environment\lib\site-packages\urllib3\util\retry.py", line 574, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.binance.binance_tld', port=443): Max retries exceeded with url: /api/v3/ping (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000022EDC0479A0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\antho\PycharmProjects\binance-trading-bot-new-coins-5\main.py", line 1, in from trade_client import * File "C:\Users\antho\PycharmProjects\binance-trading-bot-new-coins-5\trade_client.py", line 3, in client = load_binance_creds('auth/auth.yml') File "C:\Users\antho\PycharmProjects\binance-trading-bot-new-coins-5\auth\binance_auth.py", line 11, in load_binance_creds return Client(api_key = auth['binance_api'], api_secret = auth['binance_secret'], tld = "com" if 'binance_tld' not in auth else auth['binance_tld']) File "C:\Users\antho\Virtualenv Environment\lib\site-packages\binance\client.py", line 300, in init self.ping() File "C:\Users\antho\Virtualenv Environment\lib\site-packages\binance\client.py", line 526, in ping return self._get('ping', version=self.PRIVATE_API_VERSION) File "C:\Users\antho\Virtualenv Environment\lib\site-packages\binance\client.py", line 371, in _get return self._request_api('get', path, signed, version, kwargs) File "C:\Users\antho\Virtualenv Environment\lib\site-packages\binance\client.py", line 334, in _request_api return self._request(method, uri, signed, kwargs) File "C:\Users\antho\Virtualenv Environment\lib\site-packages\binance\client.py", line 314, in _request self.response = getattr(self.session, method)(uri, kwargs) File "C:\Users\antho\Virtualenv Environment\lib\site-packages\requests\sessions.py", line 555, in get return self.request('GET', url, kwargs) File "C:\Users\antho\Virtualenv Environment\lib\site-packages\requests\sessions.py", line 542, in request resp = self.send(prep, send_kwargs) File "C:\Users\antho\Virtualenv Environment\lib\site-packages\requests\sessions.py", line 655, in send r = adapter.send(request, kwargs) File "C:\Users\antho\Virtualenv Environment\lib\site-packages\requests\adapters.py", line 516, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.binance.binance_tld', port=443): Max retries exceeded with url: /api/v3/ping (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000022EDC0479A0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))

Process finished with exit code 1 `

ghost commented 2 years ago

I have the same issue, have you made any progress?

AnthoK91 commented 2 years ago

I have the same issue, have you made any progress?

No luck, unfortunately. I read that a VPN can have a significant impact on this issue, so it might be something for you to check into if you have one. Otherwise try a fresh install of Binance in Virtualenv.

None of the above worked for me.

sharnobyl commented 2 years ago

try removing " binance_tld: "BINANCE_TLD" " from auth.yml

AnthoK91 commented 2 years ago

That seemed to work @sharnobyl . Thank you very much. Though, I wonder if that is an important line? Why would it be there if not needed?

I have also seen comments on the blog referencing this error saying to set binance_tld to "com" if that helps anyone else. https://www.cryptomaton.org/2021/08/15/coding-a-binance-trading-bot-that-detects-new-coins-the-moment-they-are-listed/