# Do I need to close connections?

**URL:** <https://discuss.dgraph.io/t/do-i-need-to-close-connections/8136>\
**Category:** Dgraph Clients\
**Tags:** untagged, dgraph-js\
**Created:** [January 23, 2018, 3:44am UTC](https://discuss.dgraph.io/t/do-i-need-to-close-connections/8136 "2018-01-23T03:44:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [January 23, 2018, 3:44am UTC](https://discuss.dgraph.io/t/do-i-need-to-close-connections/8136/1 "2018-01-23T03:44:53Z")

</div>

**Moved from GitHub [dgraph-js/15](https://github.com/dgraph-io/dgraph-js/issues/15)**

_Posted by_ [vespertilian](https://github.com/vespertilian):

I have a number of scripts that all create there own connection, and I was trying to see if there was a cleanup function I need to run when I am finished with the connections and want to disconnect.

Is there a cleanup function?

Also is there a limit on connections?

I could not find answers to either of these questions, in the docs, or the code. It could be I am bad at looking.

I am planning to use DGraph via Lambda so every time a function is called it needs it’s own connection, so it’s important to understand any limits here.

It feel it would be worthwhile to have a cleanup/disconnect section after the “commit a transaction” section in these docs. I would consider adding this even if you don’t have to cleanup/disconnect as its something I often look for an answer for when working with DB clients.

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [January 24, 2018, 10:24am UTC](https://discuss.dgraph.io/t/do-i-need-to-close-connections/8136/2 "2018-01-24T10:24:03Z")

</div>

[gpahal](https://github.com/gpahal) _commented_ :

There is no limit to connections. When a new client is created using `new dgraph.DgraphClient(...DgraphClientStub)`, a new grpc channel is created for each DgraphClientStub. As long as the server can accept new connections, the client can create new channels.

The node.js grpc client v1.5 added a close method. I’ll add a method `DgraphClientStub#close()` to close the channel associated with DgraphClientStub. This will take care of cleaning up resources. There are a couple more methods that need to be exposed. They’ll be part of v1.0.1 to be released in a couple of days.

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [January 24, 2018, 1:46pm UTC](https://discuss.dgraph.io/t/do-i-need-to-close-connections/8136/3 "2018-01-24T13:46:01Z")

</div>

[gpahal](https://github.com/gpahal) _commented_ :

See [https://github.com/dgraph-io/dgraph-js#cleanup-resources](https://github.com/dgraph-io/dgraph-js#cleanup-resources) for the documentation on cleaning up resources. It’s available on v1.0.2.

---

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [July 11, 2020, 4:10am UTC](https://discuss.dgraph.io/t/do-i-need-to-close-connections/8136/4 "2020-07-11T04:10:22Z")

</div>


