Error: read ECONNRESET at TCP.onStreamRead
Now and then I get the exception below. I have to make the same request 3 times before I get a response from my NestJS API app.
[Nest] 32 - 08/03/2023, 8:08:30 AM ERROR [ExceptionsHandler] select * from "municipalities" order by "name" asc - read ECONNRESET
Error: read ECONNRESET
at TCP.onStreamRead (node:internal/stream_base_commons:217:20)
Connection Error: Connection ended unexpectedly
The above log is from NestJS API log. Can someone point me in the right direction?
35 Replies
Project ID:
79b7240f-dddf-498a-a330-e4ecb87b23f3
79b7240f-dddf-498a-a330-e4ecb87b23f3
what package are you using for the database?
I'm using knex and nestjs-knex.
can I see your connection code?
sure
It's not a problem relating to this endpoint
do me a favour and enclose that code with triple backticks?
just a second
but I'd like to see the code that connects to the database, that doesn't have anything to do with connecting to the database
Oh I see
and remember, triple backticks please
I'm doing that in my app.module.ts
show me the configuration().database code please
this is my configuration.ts
I assume this is for postgres
yes
in the
config
object can you please add this
and show me the code again after that change?2 sec
Like this?
no, not quite
in the
config
object can you please add this
is this better?
no, you aren't putting it where I'm saying to
the
pool
object goes in the config
objectyes, I see now from the doc
alright show code please
there we go
pool
is now in config
what is the significance of pool?
Yes
one sec, let me find that info for you
now this is for strapi, but the exact same information applies to you since you are using knex too, read the caution blurb
https://docs.strapi.io/dev-docs/configurations/database#database-pooling-options
are services at Railway hosted by docker containers?
yes they are
Then I understand the issue
Thanks for helping resolve my issue
alrighty then, let me know if you continue to see this issue after you deploy this change!
Okay, I will deploy and see if it solves the problem, hopefully it will
awesome
Hello Brody. Everything looks good since deployment of pool object. Thanks again for great support, it's a big incentive for us to stay on Railway platform.
I'm happy to hear that, I'm glad I could help you 🙂