Connecting postgress to API via internal network issue

Heey! I can't seem to connect my API service with DB service via internal network, the health check just fails and thats it. I'm not doing anything special, by the docs. Any ideas?
Solution:
Update, health checks can now pass if your app only listens on 0.0.0.0 but if you have already changed it to :: there's no point in changing anything back as listening on :: has no known drawbacks.
Jump to solution
16 Replies
Percy
Percy3w ago
Project ID: 3747f720-8c9c-4d81-9b13-1e420ceabd6c
essens9385
essens93853w ago
3747f720-8c9c-4d81-9b13-1e420ceabd6c
Brody
Brody3w ago
known issue with the v2 runtime that has a fix in the works, but in the mean time, what kind of app is this?
essens9385
essens93853w ago
NestJS app, do you want to know something specific?
Brody
Brody3w ago
nope that's perfect have it listen on the host :: instead of 0.0.0.0
essens9385
essens93853w ago
Oh, are you saying its because NestJS is on ipv4 and thats why ir doesen't work? But i want to use private networking for my database layer only, so not sure why changing the API layer would fix this. Do you still stand by this solution in this case?
Brody
Brody3w ago
the health check on the API is failing because the health check can only make requests to services that run on IPv6, nothing to do with your database or the private network
essens9385
essens93853w ago
ah, i see. Will try this out, thanks!
Brody
Brody3w ago
no problem
Solution
Brody
Brody3w ago
Update, health checks can now pass if your app only listens on 0.0.0.0 but if you have already changed it to :: there's no point in changing anything back as listening on :: has no known drawbacks.
essens9385
essens93853w ago
@Brody unfortunetly, this did not fix the issue for us it still fails on health check. And my guess is it fails to connect with postgress via internal network
{ json: { environment: "staging", stack: "Error: connect ECONNREFUSED fd12:be51:7a61::60:22db:e9b9:57275 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)", level: "error", from: "X", source: "TypeOrmModule", message: "Unable to connect to the database. Retrying (7)...", timestamp: "2024-06-21T10:21:04.470Z" }, http: { clientHost: "OMMITED", contentType: "application/json" } }
{ json: { environment: "staging", stack: "Error: connect ECONNREFUSED fd12:be51:7a61::60:22db:e9b9:57275 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)", level: "error", from: "X", source: "TypeOrmModule", message: "Unable to connect to the database. Retrying (7)...", timestamp: "2024-06-21T10:21:04.470Z" }, http: { clientHost: "OMMITED", contentType: "application/json" } }
Brody
Brody3w ago
the database is not running on port 57275 internally, please make sure you have all the correct environment variables in use
essens9385
essens93853w ago
if i use railways proxied public url it works fine
Brody
Brody3w ago
right but you need to use the private domain and the private port, from your error message, you are not doing that
essens9385
essens93853w ago
Ahh, you might be right. I was using the mapped port out of public domain testing now heh, what a silly mistake. It works now, thanks Brody
Brody
Brody3w ago
no problem!