Forums

Error: Failed to establish a new connection: [Errno 111] Connection refused

EDIT: I have resolved it. I was quitting the browser and not starting another browser instance.

Hi, I am trying to connect to a google sheet url to fetch a screenshot but I keep on receiving the error: Failed to establish a new connection: [Errno 111] Connection refused.

It seems that this issue is related to whitelisting the URL. But I read here that paid accounts do not have this limitation.

If it is not related to whitelisting, kindly let me know if something else is causing the issue. I'll try to rectify it.

URL: https://docs.google.com/spreadsheets/d/1L8sa3aEXS04z-0nAERrV1AW0GvkLwIt8PdqQ5RJlYOI/htmlembed/sheet?gid=1436934400&range=A1:J20

Error:

HTTPConnectionPool(host='127.0.0.1', port=33475): Max retries exceeded with url: /session/a4404090d5abc7f2c33a8879a14e0892/url (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f12307be910>: Failed to establish a new connection: [Errno 111] Connection refused'))

Code Snippet: Telegram Bot

@bot.message_handler(commands=['points'])
def points_command(message):
    try:
        browser.get("https://docs.google.com/spreadsheets/d/1L8sa3aEXS04z-0nAERrV1AW0GvkLwIt8PdqQ5RJlYOI/htmlembed/sheet?gid=1436934400&range=A1:J20")
        browser.save_screenshot('points_table.png')

    finally:
        browser.quit()

    bot.send_chat_action(message.chat.id, 'upload_photo')
    img = open('points_table.png', 'rb')
    bot.send_photo(message.chat.id, img, reply_to_message_id=message.message_id)
    img.close()

Where are you getting this error message? It doesn't seem to match the code you pasted.