# Question about TCP and IPC handles limit

**URL:** <https://forum.kx.com/t/question-about-tcp-and-ipc-handles-limit/13967>\
**Category:** Community Support\
**Tags:** imported, kdb-and-q\
**Created:** [June 27, 2024, 2:17pm UTC](https://forum.kx.com/t/question-about-tcp-and-ipc-handles-limit/13967 "2024-06-27T14:17:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![abubo](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@abubo](https://forum.kx.com/u/abubo)\
**Post date:** [June 27, 2024, 2:17pm UTC](https://forum.kx.com/t/question-about-tcp-and-ipc-handles-limit/13967/1 "2024-06-27T14:17:47Z")

</div>

[https://learninghub.kx.com/forums/topic/question-about-tcp-and-ipc-handles-limit](https://learninghub.kx.com/forums/topic/question-about-tcp-and-ipc-handles-limit)

I use CsharpKDB to talk to KDB+ and found an issue to keep too many connection/handle to the port. Seems there is a limit that I cannot keep adding connections to more than 1008. And CsharpKDB c.close() doesn't appears to reduce the existing open connections.   
  
It is easy to demo using IPC:  
on server side:  
\>q.exe -p 5001  
q)count .z.H  
0  
  
at client side:  
\>q  
q)h:hopen `::5001q){h:hopen`::12345} each til 1009

'hop. OS reports: An existing connection was forcibly closed by the remote host.

The server side will pop error 'conn as well.  
  
Is this limit of 1008 an OS setting or q.exe limit? Anyway to work around it?

Thanks,

Ning

---

<div class="post-metadata">

**Author:** ![rocuinneagain](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/rocuinneagain/32/287_2.png) [@rocuinneagain](https://forum.kx.com/u/rocuinneagain)\
**Post date:** [July 1, 2024, 10:14am UTC](https://forum.kx.com/t/question-about-tcp-and-ipc-handles-limit/13967/2 "2024-07-01T10:14:50Z")

</div>

This limitation was removed in 4.1 release

https://code.kx.com/q/basics/errors/#runtime-errors

_conn_

_Too many connections. Max connections was 1022 prior to 4.1t 2023.09.15, otherwise the limit imposed by the operating system (operating system configurable for system/protocol)._

  

https://code.kx.com/q/releases/ChangesIn4.1/#unlimited-ipcwebsocket-connections

  
_The number of connections is now limited only by the operating system and protocol settings (system configurable)._

---

<div class="post-metadata">

**Author:** ![rocuinneagain](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/rocuinneagain/32/287_2.png) [@rocuinneagain](https://forum.kx.com/u/rocuinneagain)\
**Post date:** [July 1, 2024, 10:24am UTC](https://forum.kx.com/t/question-about-tcp-and-ipc-handles-limit/13967/3 "2024-07-01T10:24:39Z")

</div>

https://code.kx.com/q/ref/dotz/#zpo-open

https://code.kx.com/q/ref/dotz/#zpc-close

You can use callbacks to see when handles open and close

```
.z.po:{string[.z.p]," opened ",string x;x}
.z.pc:{string[.z.p]," closed ",string x;x}
```

Test this against your c.Close() calls to confirm it is closing the handles.

If still seeing a problem raising an issue can be done at: https://github.com/KxSystems/csharpkdb/issues
