Closed Nekoraru22 closed 2 years ago
Most likely a security thing with replit
Yeah I am having the same error as I'm using it on a Discord bot of mine. It works fine locally on my code editor, but doesn't work on Replit.
I tried to request the nekos.life API manually by requests module, and I got a different exception.
The code I used was:
image = requests.get("https://nekos.life/api/v2/img/meow")
url = json.loads(image.text)["url"]
I have used requests and json module for the code above.
And I got a big error almost similar to the normal one:
Ignoring exception in command catplease:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/urllib3/connection.py", line 174, in _new_conn
conn = connection.create_connection(
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/urllib3/util/connection.py", line 96, in create_connection
raise err
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/urllib3/util/connection.py", line 86, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 382, in _make_request
self._validate_conn(conn)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1010, in _validate_conn
conn.connect()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/urllib3/connection.py", line 358, in connect
conn = self._new_conn()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/urllib3/connection.py", line 186, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f8e8597e9a0>: Failed to establish a new connection: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/urllib3/connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/urllib3/util/retry.py", line 574, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='nekos.life', port=443): Max retries exceeded with url: /api/v2/img/meow (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f8e8597e9a0>: Failed to establish a new connection: [Errno 111] Connection refused'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 163, in catplease
image = json.loads(requests.get("https://nekos.life/api/v2/img/meow").text)["url"]
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/requests/api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='nekos.life', port=443): Max retries exceeded with url: /api/v2/img/meow (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f8e8597e9a0>: Failed to establish a new connection: [Errno 111] Connection refused'))
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ConnectionError: HTTPSConnectionPool(host='nekos.life', port=443): Max retries exceeded with url: /api/v2/img/meow (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f8e8597e9a0>: Failed to establish a new connection: [Errno 111] Connection refused'))
It doesn't seem to be a problem of the package itself but rather something else, probably Replit is running into some issues connecting with the API, because as said before the API runs fine locally for me. I searched the "Max retries exceeded, Errno 111 Connection refused" topic online and it seems that it's a common issue with the requests module, but could not find a solution which works on Replit.
I've been using this library for a long time, I really like it, but recently it stopped working at Replit :(
I don't know if you can do anything to fix this or it's the page's problem, thanks anyway!