# Transaction already started error

**URL:** <https://forum.elixirforum.com/t/transaction-already-started-error/52448>\
**Category:** Questions\
**Tags:** ecto, db\_connection\
**Created:** [December 12, 2022, 12:00pm UTC](https://forum.elixirforum.com/t/transaction-already-started-error/52448 "2022-12-12T12:00:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![0xAX](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/0xax/32/28823_2.png) [@0xAX](https://forum.elixirforum.com/u/0xAX)\
**Post date:** [December 12, 2022, 12:00pm UTC](https://forum.elixirforum.com/t/transaction-already-started-error/52448/1 "2022-12-12T12:00:37Z")

</div>

Hello everyone,

Time to time I see that database sockets are closed during running my Elixir application. Except pretty terse `<<"socket closed">>` error today I saw `transaction is already started error`, the full text is:

```elixir
2022-12-12-10:09:08.355 [error] MyXQL.Connection (#PID<0.2291.0>) disconnected: 
**(DBConnection.TransactionError) transaction is already started

```

Besides the text of the error message is pretty clear on itself 🙂 I am still don’t understand under which conditions `db_connection` library may throw this exception and would appreciate if somebody can give me any hints how this error could be reproduced based on abstract (maybe failed) transactions and what reason for this error.

Unfortunately I can’t provide the query or whole transaction where the exception is thrown as there are many of them and I am still not sure by myself which one causes it.

Thank you.
