Replit Python 3.10 requests: Connection refused

I try use requests library to make request. Using Python 3.10 Replit

import requests
import json

async def check365(interaction: discord.Interaction):
        await interaction.response.defer(ephemeral=False)
        # data = message
        r = requests.get(
#Res is: [{'username': 'a', 'password': 'b', 'status': 'valid'}]
        res = json.loads(r.text)
        mess = ''
        if res[0]['status'] == 'valid':
            mess = 'ok'
            mess = 'fail'
        await interaction.followup.send("Message: " + " --> " + mess)

but i have a error:

ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:

Some post say change: https to http, i had try but not work…
I had try on Visual Studio, and this code work. When i push to replit and that not work… Anyone can help me…

1 Like
  1. Whats the site you’re sending requests to.
  2. Discord bot interaction?

i’m using discord lib for send and read mess on my Discord Server

That is nt private api, so i can’t public. Have any way to fix that error?

ConnectionRefusedError: [Errno 111] Connection refused It’s possible that the API isn’t functioning properly or is returning an error. Please check the API status to ensure that everything is in working order

try after a kill 1 in shell :confused:

I notice that you are using requests with async, this is blocking and could cause problems in the future. it is recommended to use aiohttp for http request and async.