Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python -- ConnectionError: Max retries exceeded

I occasionally get this error when my server (call it Server A) makes requests to a resource on another one of my servers (all it Server B):

ConnectionError: HTTPConnectionPool(host='some_ip', port=some_port): Max retries exceeded with url: /some_url/ (Caused by : [Errno 111] Connection refused)

The message in the exception is
message : None: Max retries exceeded with url: /some_url/ (Caused by redirect)
which I include because it has that extra piece of information (caused by redirect).

As I said, I control both servers involved in this request, so I can make changes to either and/or both. Also, the error appears to be intermittent, in that it doesn't happen every time.

Potentially relevant information -- Server A is a Python server running apache, and Server B is a NodeJS server. I am not exactly a web server wizard, so beyond that, I'm not exactly sure what information would be relevant.

Does anyone know exactly what this error means, or how to go about investigating a fix? Or, does anyone know which server is likely to be the problem, the one making the request, or the one receiving it?

Edit: The error has begun happening with our calls to external web resources also.

like image 820
Clay Wardell Avatar asked Feb 11 '13 18:02

Clay Wardell


1 Answers

You are getting a CONN Refused on "some_ip" and port. That's likely caused by - No server actually listening on that port/IP combination - Firewall settings that send Conn Refused (less likely a cause!) - Third - a misconfigured (more likely) or busy server, that cannot handle requests.

I Believe When - server A is trying to connect to server B you are getting that error. (Assuming it's Linux and/or some unix derivative) what does netstat -ln -tcp show on the server? (man netstat to understand the flags - what we are doing here is - trying to find which all programs are listening on which port). If that indeed shows your server B listening - iptables -L -n to show the firewall rules. If nothing's wrong there - it's a bad configuration of listen queue most probably. (http://www.linuxjournal.com/files/linuxjournal.com/linuxjournal/articles/023/2333/2333s2.html) or google for listen backlog.

This most likely is a bad configuration issue on your server B. (Note: a redirect loop as someone mentioned above - not handled correctly could just end up making the server busy! so possibly solving that could solve your problem as well)

like image 129
gabhijit Avatar answered Oct 13 '22 15:10

gabhijit