Python - ConnectionRefusedError, urllib3.exceptions.NewConnectionError and Colorama





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















So today I was using a script I wrote myself where I noticed that something was wrong. I ran my program with using multiprocessing for few hours and then I got hit with different errors.



The first one is:



Problem1



The second one is:



Problem2



The last one:



Traceback (most recent call last):
self.wrapped.write(text[start:end])
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 40, in write
self.__convertor.write(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 141, in write
self.write_and_convert(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 169, in write_and_convert
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 40, in write
self.__convertor.write(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 141, in write
self.write_and_convert(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 169, in write_and_convert
self.write_plain_text(text, cursor, len(text)) File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 174, in write_plain_text
self.wrapped.write(text[start:end])
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 40, in write
self.__convertor.write(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 141, in write
self.write_and_convert(text)
self.wrapped.write(text[start:end])
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 40, in write
self.__convertor.write(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 141, in write
self.write_and_convert(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 169, in write_and_convert
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 169, in write_and_convert
self.write_plain_text(text, cursor, len(text))
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 174, in write_plain_text
self.wrapped.write(text[start:end])
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 40, in write
self.__convertor.write(text)


The problem is that I tried to search for all these three problems where I didnt really found information for Python but I want to ask you guys what does errors means which I can learn what they do and also I also want to know how I would be possible able to avoid them/or retry if it hits with try - except I assume?



Similar stuff what I do is following:



logger = Logger(value)
while True:

try:
url = 'https://www.google.com'

headers = {
'User-Agent': ('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36'
' (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36')
}

requests.packages.urllib3.disable_warnings()
resp = requests.get(url, headers=headers, verify=False, proxies=get_random_proxy(), timeout=12)
resp.raise_for_status()

if resp.status_code == 200 or 301:
return resp.url

except HTTPError as err:
randomtime = random.randint(0, 1)
logger.error('Error HTTPError! - Retrying in {} secs'.format(randomtime))
time.sleep(randomtime)
continue


except requests.exceptions.ConnectionError as err:
randomtime = random.randint(0, 1)
logger.error('Error ConnectionError proxy! - Retrying in {} secs'.format(randomtime))
time.sleep(randomtime)
continue

except requests.exceptions.RequestException as err:
randomtime = random.randint(0, 1)
logger.error('Request error proxy! - Retrying in {} secs'.format(randomtime))
time.sleep(randomtime)
continue

except ssl.SSLWantWriteError:
randomtime = random.randint(0, 1)
logger.error('SSL Write Error! - Retrying in {} secs'.format(randomtime))
time.sleep(randomtime)
continue

except ssl.SSLError as err:
randomtime = random.randint(0, 1)
logger.error('SSL ERROR!n {} - Retrying in {} secs'.format(err, randomtime))
time.sleep(randomtime)
continue


My guess to not getting these error is maybet o do something like



except ConnectionRefusedError as err:
randomtime = random.randint(0, 1)
logger.error('ERROR!n {} - Retrying in {} secs'.format(err, randomtime))
time.sleep(randomtime)
continue

except request.exceptions.ProxyError as err:
randomtime = random.randint(0, 1)
logger.error('ERROR!n {} - Retrying in {} secs'.format(err, randomtime))
time.sleep(randomtime)
continue


Im not sure but I would appreciate for anything. Anything would be appreciated!










share|improve this question























  • If you're getting ConnectionRefusedError or ProxyError, simply trying again is very unlikely to work. Those errors mean something is actually wrong, and will have to be fixed.

    – John Gordon
    Nov 23 '18 at 19:50











  • In which way could they be wrong if I might ask and what are you suggestions basically to solve it? @JohnGordon

    – Hellosiroverthere
    Nov 23 '18 at 19:53











  • ConnectionRefusedError means that the remote host can't, or doesn't want to, answer your request. Fixing it would depend on why the host isn't answering. Maybe you're trying to connect on the wrong port number, in which case the fix is obvious -- use the correct port number. Or maybe the host is configured to reject requests from your IP address, in which case there's nothing you can do.

    – John Gordon
    Nov 23 '18 at 20:01













  • Oh so that means at the end that it could be an Proxy that can be causing it aswell that made the connectionRefusedError to actually happend?

    – Hellosiroverthere
    Nov 23 '18 at 20:05











  • I don't know a lot about proxies; I suppose it could happen that way.

    – John Gordon
    Nov 23 '18 at 20:06




















1















So today I was using a script I wrote myself where I noticed that something was wrong. I ran my program with using multiprocessing for few hours and then I got hit with different errors.



The first one is:



Problem1



The second one is:



Problem2



The last one:



Traceback (most recent call last):
self.wrapped.write(text[start:end])
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 40, in write
self.__convertor.write(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 141, in write
self.write_and_convert(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 169, in write_and_convert
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 40, in write
self.__convertor.write(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 141, in write
self.write_and_convert(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 169, in write_and_convert
self.write_plain_text(text, cursor, len(text)) File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 174, in write_plain_text
self.wrapped.write(text[start:end])
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 40, in write
self.__convertor.write(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 141, in write
self.write_and_convert(text)
self.wrapped.write(text[start:end])
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 40, in write
self.__convertor.write(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 141, in write
self.write_and_convert(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 169, in write_and_convert
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 169, in write_and_convert
self.write_plain_text(text, cursor, len(text))
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 174, in write_plain_text
self.wrapped.write(text[start:end])
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 40, in write
self.__convertor.write(text)


The problem is that I tried to search for all these three problems where I didnt really found information for Python but I want to ask you guys what does errors means which I can learn what they do and also I also want to know how I would be possible able to avoid them/or retry if it hits with try - except I assume?



Similar stuff what I do is following:



logger = Logger(value)
while True:

try:
url = 'https://www.google.com'

headers = {
'User-Agent': ('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36'
' (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36')
}

requests.packages.urllib3.disable_warnings()
resp = requests.get(url, headers=headers, verify=False, proxies=get_random_proxy(), timeout=12)
resp.raise_for_status()

if resp.status_code == 200 or 301:
return resp.url

except HTTPError as err:
randomtime = random.randint(0, 1)
logger.error('Error HTTPError! - Retrying in {} secs'.format(randomtime))
time.sleep(randomtime)
continue


except requests.exceptions.ConnectionError as err:
randomtime = random.randint(0, 1)
logger.error('Error ConnectionError proxy! - Retrying in {} secs'.format(randomtime))
time.sleep(randomtime)
continue

except requests.exceptions.RequestException as err:
randomtime = random.randint(0, 1)
logger.error('Request error proxy! - Retrying in {} secs'.format(randomtime))
time.sleep(randomtime)
continue

except ssl.SSLWantWriteError:
randomtime = random.randint(0, 1)
logger.error('SSL Write Error! - Retrying in {} secs'.format(randomtime))
time.sleep(randomtime)
continue

except ssl.SSLError as err:
randomtime = random.randint(0, 1)
logger.error('SSL ERROR!n {} - Retrying in {} secs'.format(err, randomtime))
time.sleep(randomtime)
continue


My guess to not getting these error is maybet o do something like



except ConnectionRefusedError as err:
randomtime = random.randint(0, 1)
logger.error('ERROR!n {} - Retrying in {} secs'.format(err, randomtime))
time.sleep(randomtime)
continue

except request.exceptions.ProxyError as err:
randomtime = random.randint(0, 1)
logger.error('ERROR!n {} - Retrying in {} secs'.format(err, randomtime))
time.sleep(randomtime)
continue


Im not sure but I would appreciate for anything. Anything would be appreciated!










share|improve this question























  • If you're getting ConnectionRefusedError or ProxyError, simply trying again is very unlikely to work. Those errors mean something is actually wrong, and will have to be fixed.

    – John Gordon
    Nov 23 '18 at 19:50











  • In which way could they be wrong if I might ask and what are you suggestions basically to solve it? @JohnGordon

    – Hellosiroverthere
    Nov 23 '18 at 19:53











  • ConnectionRefusedError means that the remote host can't, or doesn't want to, answer your request. Fixing it would depend on why the host isn't answering. Maybe you're trying to connect on the wrong port number, in which case the fix is obvious -- use the correct port number. Or maybe the host is configured to reject requests from your IP address, in which case there's nothing you can do.

    – John Gordon
    Nov 23 '18 at 20:01













  • Oh so that means at the end that it could be an Proxy that can be causing it aswell that made the connectionRefusedError to actually happend?

    – Hellosiroverthere
    Nov 23 '18 at 20:05











  • I don't know a lot about proxies; I suppose it could happen that way.

    – John Gordon
    Nov 23 '18 at 20:06
















1












1








1








So today I was using a script I wrote myself where I noticed that something was wrong. I ran my program with using multiprocessing for few hours and then I got hit with different errors.



The first one is:



Problem1



The second one is:



Problem2



The last one:



Traceback (most recent call last):
self.wrapped.write(text[start:end])
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 40, in write
self.__convertor.write(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 141, in write
self.write_and_convert(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 169, in write_and_convert
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 40, in write
self.__convertor.write(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 141, in write
self.write_and_convert(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 169, in write_and_convert
self.write_plain_text(text, cursor, len(text)) File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 174, in write_plain_text
self.wrapped.write(text[start:end])
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 40, in write
self.__convertor.write(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 141, in write
self.write_and_convert(text)
self.wrapped.write(text[start:end])
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 40, in write
self.__convertor.write(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 141, in write
self.write_and_convert(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 169, in write_and_convert
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 169, in write_and_convert
self.write_plain_text(text, cursor, len(text))
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 174, in write_plain_text
self.wrapped.write(text[start:end])
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 40, in write
self.__convertor.write(text)


The problem is that I tried to search for all these three problems where I didnt really found information for Python but I want to ask you guys what does errors means which I can learn what they do and also I also want to know how I would be possible able to avoid them/or retry if it hits with try - except I assume?



Similar stuff what I do is following:



logger = Logger(value)
while True:

try:
url = 'https://www.google.com'

headers = {
'User-Agent': ('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36'
' (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36')
}

requests.packages.urllib3.disable_warnings()
resp = requests.get(url, headers=headers, verify=False, proxies=get_random_proxy(), timeout=12)
resp.raise_for_status()

if resp.status_code == 200 or 301:
return resp.url

except HTTPError as err:
randomtime = random.randint(0, 1)
logger.error('Error HTTPError! - Retrying in {} secs'.format(randomtime))
time.sleep(randomtime)
continue


except requests.exceptions.ConnectionError as err:
randomtime = random.randint(0, 1)
logger.error('Error ConnectionError proxy! - Retrying in {} secs'.format(randomtime))
time.sleep(randomtime)
continue

except requests.exceptions.RequestException as err:
randomtime = random.randint(0, 1)
logger.error('Request error proxy! - Retrying in {} secs'.format(randomtime))
time.sleep(randomtime)
continue

except ssl.SSLWantWriteError:
randomtime = random.randint(0, 1)
logger.error('SSL Write Error! - Retrying in {} secs'.format(randomtime))
time.sleep(randomtime)
continue

except ssl.SSLError as err:
randomtime = random.randint(0, 1)
logger.error('SSL ERROR!n {} - Retrying in {} secs'.format(err, randomtime))
time.sleep(randomtime)
continue


My guess to not getting these error is maybet o do something like



except ConnectionRefusedError as err:
randomtime = random.randint(0, 1)
logger.error('ERROR!n {} - Retrying in {} secs'.format(err, randomtime))
time.sleep(randomtime)
continue

except request.exceptions.ProxyError as err:
randomtime = random.randint(0, 1)
logger.error('ERROR!n {} - Retrying in {} secs'.format(err, randomtime))
time.sleep(randomtime)
continue


Im not sure but I would appreciate for anything. Anything would be appreciated!










share|improve this question














So today I was using a script I wrote myself where I noticed that something was wrong. I ran my program with using multiprocessing for few hours and then I got hit with different errors.



The first one is:



Problem1



The second one is:



Problem2



The last one:



Traceback (most recent call last):
self.wrapped.write(text[start:end])
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 40, in write
self.__convertor.write(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 141, in write
self.write_and_convert(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 169, in write_and_convert
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 40, in write
self.__convertor.write(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 141, in write
self.write_and_convert(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 169, in write_and_convert
self.write_plain_text(text, cursor, len(text)) File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 174, in write_plain_text
self.wrapped.write(text[start:end])
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 40, in write
self.__convertor.write(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 141, in write
self.write_and_convert(text)
self.wrapped.write(text[start:end])
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 40, in write
self.__convertor.write(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 141, in write
self.write_and_convert(text)
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 169, in write_and_convert
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 169, in write_and_convert
self.write_plain_text(text, cursor, len(text))
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 174, in write_plain_text
self.wrapped.write(text[start:end])
File "C:Program FilesPython36libsite-packagescoloramaansitowin32.py", line 40, in write
self.__convertor.write(text)


The problem is that I tried to search for all these three problems where I didnt really found information for Python but I want to ask you guys what does errors means which I can learn what they do and also I also want to know how I would be possible able to avoid them/or retry if it hits with try - except I assume?



Similar stuff what I do is following:



logger = Logger(value)
while True:

try:
url = 'https://www.google.com'

headers = {
'User-Agent': ('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36'
' (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36')
}

requests.packages.urllib3.disable_warnings()
resp = requests.get(url, headers=headers, verify=False, proxies=get_random_proxy(), timeout=12)
resp.raise_for_status()

if resp.status_code == 200 or 301:
return resp.url

except HTTPError as err:
randomtime = random.randint(0, 1)
logger.error('Error HTTPError! - Retrying in {} secs'.format(randomtime))
time.sleep(randomtime)
continue


except requests.exceptions.ConnectionError as err:
randomtime = random.randint(0, 1)
logger.error('Error ConnectionError proxy! - Retrying in {} secs'.format(randomtime))
time.sleep(randomtime)
continue

except requests.exceptions.RequestException as err:
randomtime = random.randint(0, 1)
logger.error('Request error proxy! - Retrying in {} secs'.format(randomtime))
time.sleep(randomtime)
continue

except ssl.SSLWantWriteError:
randomtime = random.randint(0, 1)
logger.error('SSL Write Error! - Retrying in {} secs'.format(randomtime))
time.sleep(randomtime)
continue

except ssl.SSLError as err:
randomtime = random.randint(0, 1)
logger.error('SSL ERROR!n {} - Retrying in {} secs'.format(err, randomtime))
time.sleep(randomtime)
continue


My guess to not getting these error is maybet o do something like



except ConnectionRefusedError as err:
randomtime = random.randint(0, 1)
logger.error('ERROR!n {} - Retrying in {} secs'.format(err, randomtime))
time.sleep(randomtime)
continue

except request.exceptions.ProxyError as err:
randomtime = random.randint(0, 1)
logger.error('ERROR!n {} - Retrying in {} secs'.format(err, randomtime))
time.sleep(randomtime)
continue


Im not sure but I would appreciate for anything. Anything would be appreciated!







python error-handling compiler-errors try-catch






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 23 '18 at 19:46









HellosiroverthereHellosiroverthere

11718




11718













  • If you're getting ConnectionRefusedError or ProxyError, simply trying again is very unlikely to work. Those errors mean something is actually wrong, and will have to be fixed.

    – John Gordon
    Nov 23 '18 at 19:50











  • In which way could they be wrong if I might ask and what are you suggestions basically to solve it? @JohnGordon

    – Hellosiroverthere
    Nov 23 '18 at 19:53











  • ConnectionRefusedError means that the remote host can't, or doesn't want to, answer your request. Fixing it would depend on why the host isn't answering. Maybe you're trying to connect on the wrong port number, in which case the fix is obvious -- use the correct port number. Or maybe the host is configured to reject requests from your IP address, in which case there's nothing you can do.

    – John Gordon
    Nov 23 '18 at 20:01













  • Oh so that means at the end that it could be an Proxy that can be causing it aswell that made the connectionRefusedError to actually happend?

    – Hellosiroverthere
    Nov 23 '18 at 20:05











  • I don't know a lot about proxies; I suppose it could happen that way.

    – John Gordon
    Nov 23 '18 at 20:06





















  • If you're getting ConnectionRefusedError or ProxyError, simply trying again is very unlikely to work. Those errors mean something is actually wrong, and will have to be fixed.

    – John Gordon
    Nov 23 '18 at 19:50











  • In which way could they be wrong if I might ask and what are you suggestions basically to solve it? @JohnGordon

    – Hellosiroverthere
    Nov 23 '18 at 19:53











  • ConnectionRefusedError means that the remote host can't, or doesn't want to, answer your request. Fixing it would depend on why the host isn't answering. Maybe you're trying to connect on the wrong port number, in which case the fix is obvious -- use the correct port number. Or maybe the host is configured to reject requests from your IP address, in which case there's nothing you can do.

    – John Gordon
    Nov 23 '18 at 20:01













  • Oh so that means at the end that it could be an Proxy that can be causing it aswell that made the connectionRefusedError to actually happend?

    – Hellosiroverthere
    Nov 23 '18 at 20:05











  • I don't know a lot about proxies; I suppose it could happen that way.

    – John Gordon
    Nov 23 '18 at 20:06



















If you're getting ConnectionRefusedError or ProxyError, simply trying again is very unlikely to work. Those errors mean something is actually wrong, and will have to be fixed.

– John Gordon
Nov 23 '18 at 19:50





If you're getting ConnectionRefusedError or ProxyError, simply trying again is very unlikely to work. Those errors mean something is actually wrong, and will have to be fixed.

– John Gordon
Nov 23 '18 at 19:50













In which way could they be wrong if I might ask and what are you suggestions basically to solve it? @JohnGordon

– Hellosiroverthere
Nov 23 '18 at 19:53





In which way could they be wrong if I might ask and what are you suggestions basically to solve it? @JohnGordon

– Hellosiroverthere
Nov 23 '18 at 19:53













ConnectionRefusedError means that the remote host can't, or doesn't want to, answer your request. Fixing it would depend on why the host isn't answering. Maybe you're trying to connect on the wrong port number, in which case the fix is obvious -- use the correct port number. Or maybe the host is configured to reject requests from your IP address, in which case there's nothing you can do.

– John Gordon
Nov 23 '18 at 20:01







ConnectionRefusedError means that the remote host can't, or doesn't want to, answer your request. Fixing it would depend on why the host isn't answering. Maybe you're trying to connect on the wrong port number, in which case the fix is obvious -- use the correct port number. Or maybe the host is configured to reject requests from your IP address, in which case there's nothing you can do.

– John Gordon
Nov 23 '18 at 20:01















Oh so that means at the end that it could be an Proxy that can be causing it aswell that made the connectionRefusedError to actually happend?

– Hellosiroverthere
Nov 23 '18 at 20:05





Oh so that means at the end that it could be an Proxy that can be causing it aswell that made the connectionRefusedError to actually happend?

– Hellosiroverthere
Nov 23 '18 at 20:05













I don't know a lot about proxies; I suppose it could happen that way.

– John Gordon
Nov 23 '18 at 20:06







I don't know a lot about proxies; I suppose it could happen that way.

– John Gordon
Nov 23 '18 at 20:06














1 Answer
1






active

oldest

votes


















0














Was having a similar issue, tried to catch it with the exception from builtins:



from builtins import ConnectionRefusedError


which seemed like the most obvious solution, however the following worked:



requests.exceptions.ConnectionError


see here






share|improve this answer


























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53452227%2fpython-connectionrefusederror-urllib3-exceptions-newconnectionerror-and-color%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Was having a similar issue, tried to catch it with the exception from builtins:



    from builtins import ConnectionRefusedError


    which seemed like the most obvious solution, however the following worked:



    requests.exceptions.ConnectionError


    see here






    share|improve this answer






























      0














      Was having a similar issue, tried to catch it with the exception from builtins:



      from builtins import ConnectionRefusedError


      which seemed like the most obvious solution, however the following worked:



      requests.exceptions.ConnectionError


      see here






      share|improve this answer




























        0












        0








        0







        Was having a similar issue, tried to catch it with the exception from builtins:



        from builtins import ConnectionRefusedError


        which seemed like the most obvious solution, however the following worked:



        requests.exceptions.ConnectionError


        see here






        share|improve this answer















        Was having a similar issue, tried to catch it with the exception from builtins:



        from builtins import ConnectionRefusedError


        which seemed like the most obvious solution, however the following worked:



        requests.exceptions.ConnectionError


        see here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jan 28 at 14:31

























        answered Jan 28 at 14:18









        cardamomcardamom

        2,08811344




        2,08811344
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53452227%2fpython-connectionrefusederror-urllib3-exceptions-newconnectionerror-and-color%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown