# \[WinError 10054\] An existing connection was forcibly closed by the remote host

**URL:** <https://discourse.nameko.io/t/winerror-10054-an-existing-connection-was-forcibly-closed-by-the-remote-host/506>\
**Category:** Uncategorized\
**Created:** [October 15, 2019, 11:36am UTC](https://discourse.nameko.io/t/winerror-10054-an-existing-connection-was-forcibly-closed-by-the-remote-host/506 "2019-10-15T11:36:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![manish.leonine](https://avatars.discourse-cdn.com/v4/letter/m/7993a0/32.png) [@manish.leonine](https://discourse.nameko.io/u/manish.leonine)\
**Post date:** [October 15, 2019, 11:36am UTC](https://discourse.nameko.io/t/winerror-10054-an-existing-connection-was-forcibly-closed-by-the-remote-host/506/1 "2019-10-15T11:36:17Z")

</div>

I am getting this error on Windows Server class VM with nameko version 2.12.0. Kombu Version 4.6.5.

[2019-10-15 19:27:48,608] [INFO] [nameko.containers] [containers.py] [kill():282] [PID:10996 TID:1401349262832] - killing \<ServiceContainer [wind\_api\_data\_service] at 0x14601b699e8\> due to [WinError 10054] An existing connection was forcibly closed by the remote host  
[2019-10-15 19:27:48,611] [WARNING] [kombu.mixins] [mixins.py] [run():180] [PID:10996 TID:1400188214008] - Connection to broker lost, trying to re-establish connection…  
Traceback (most recent call last):  
File “E:\QF\inv\_qf5\App\wind\_services\venv\lib\site-packages\kombu\mixins.py”, line 175, in run  
for \_ in self.consume(limit=None, \*\*kwargs):  
File “E:\QF\inv\_qf5\App\wind\_services\venv\lib\site-packages\kombu\mixins.py”, line 197, in consume  
conn.drain\_events(timeout=safety\_interval)  
File “E:\QF\inv\_qf5\App\wind\_services\venv\lib\site-packages\kombu\connection.py”, line 323, in drain\_events  
return self.transport.drain\_events(self.connection, \*\*kwargs)  
File “E:\QF\inv\_qf5\App\wind\_services\venv\lib\site-packages\kombu\transport\pyamqp.py”, line 103, in drain\_events  
return connection.drain\_events(\*\*kwargs)  
File “E:\QF\inv\_qf5\App\wind\_services\venv\lib\site-packages\amqp\connection.py”, line 505, in drain\_events  
while not self.blocking\_read(timeout):  
File “E:\QF\inv\_qf5\App\wind\_services\venv\lib\site-packages\amqp\connection.py”, line 510, in blocking\_read  
frame = self.transport.read\_frame()  
File “E:\QF\inv\_qf5\App\wind\_services\venv\lib\site-packages\amqp\transport.py”, line 252, in read\_frame  
frame\_header = read(7, True)  
File “E:\QF\inv\_qf5\App\wind\_services\venv\lib\site-packages\amqp\transport.py”, line 446, in \_read  
raise IOError(‘Server unexpectedly closed connection’)  
OSError: Server unexpectedly closed connection

---

<div class="post-metadata">

**Author:** ![mattbennett](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/mattbennett/32/13_2.png) [@mattbennett](https://discourse.nameko.io/u/mattbennett)\
**Post date:** [October 15, 2019, 7:21pm UTC](https://discourse.nameko.io/t/winerror-10054-an-existing-connection-was-forcibly-closed-by-the-remote-host/506/2 "2019-10-15T19:21:00Z")

</div>

Hi @manish.leonine,

Your service is losing connection to the RabbitMQ broker. It should attempt to reconnect, as stated in the log. Does it not succeed?

How are you running and connecting to the broker?

---

<div class="post-metadata">

**Author:** ![manish.leonine](https://avatars.discourse-cdn.com/v4/letter/m/7993a0/32.png) [@manish.leonine](https://discourse.nameko.io/u/manish.leonine)\
**Post date:** [October 16, 2019, 4:19am UTC](https://discourse.nameko.io/t/winerror-10054-an-existing-connection-was-forcibly-closed-by-the-remote-host/506/3 "2019-10-16T04:19:52Z")

</div>

Hi Mat,

It connects in some attempts but fails for others. Any thing specific on the heartbeat and timeout that can be tweaked to make the reconnect more effective?

---

<div class="post-metadata">

**Author:** ![mattbennett](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.nameko.io/mattbennett/32/13_2.png) [@mattbennett](https://discourse.nameko.io/u/mattbennett)\
**Post date:** [October 16, 2019, 7:08pm UTC](https://discourse.nameko.io/t/winerror-10054-an-existing-connection-was-forcibly-closed-by-the-remote-host/506/4 "2019-10-16T19:08:32Z")

</div>

Attempting to reconnect is the intended behaviour. There’s nothing Nameko can do if the server can’t be reached though. It sounds like you’ve got something going on with the network connection to RabbitMQ. Is this on the same machine, LAN or WAN?

You can reduce the heartbeat to discover a broken connection sooner – simply set `HEARTBEAT: <value-in-seconds>` in your config file. But this will not make reconnection more effective I’m afraid.
