Unable to connect to pgvector.railway.internal

Hi I am unable to connect with my pgvector postgres db. receiving the following error getaddrinfo ENOTFOUND pgvector.railway.internal for my sveltekit app (using dockerfile) I added 3 second sleep. and for both pgvector and sveltekit added ENABLE_ALPINE_PRIVATE_NETWORKING=true in variables sveltekit app project id 94b0bba1-afce-4b74-ac49-8aa1fb06163e pgvector project id 171d055d-0855-415c-8f03-8b52fb322141
Solution:
your database and app are in different projects right? if so, they need to be in the same project
Jump to solution
17 Replies
Percy
Percy2mo ago
Project ID: 94b0bba1-afce-4b74-ac49-8aa1fb06163e,171d055d-0855-415c-8f03-8b52fb322141
Brody
Brody2mo ago
do you get that error locally?
SSSuryaa
SSSuryaaOP2mo ago
no, for local I am using external url for db so did not got this error postgresql://postgres:[email protected]:45850/railway this is my connection string if its of any help. I have replaced actual password with PASSWORD the following connection string is working postgresql://postgres:[email protected]:45850/railway
SSSuryaa
SSSuryaaOP2mo ago
locally internal networking is not working
No description
Brody
Brody2mo ago
you are using the private url locally, you need to use the public url
SSSuryaa
SSSuryaaOP2mo ago
using public url locally the issue I am facing is for the one hosted on railway using internal url please check this healthcheck endpoint https://betterfaq-production.up.railway.app/healthz
// src/routes/healthz/+server.js
import { sql } from '$lib/server/db/client';
import { json } from '@sveltejs/kit';

export async function GET() {
try {
await sql`SELECT 1'`;
return json({ status: 'OK' }, { status: 200 });
} catch (error) {
// Check if the error is an instance of Error
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
return json({ status: 'Service Unavailable', error: errorMessage }, { status: 503 });
}
}
// src/routes/healthz/+server.js
import { sql } from '$lib/server/db/client';
import { json } from '@sveltejs/kit';

export async function GET() {
try {
await sql`SELECT 1'`;
return json({ status: 'OK' }, { status: 200 });
} catch (error) {
// Check if the error is an instance of Error
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
return json({ status: 'Service Unavailable', error: errorMessage }, { status: 503 });
}
}
code for healthcheck endpoint which only checks if db is connected or not === just to reiterate, using internal for connecting the application hosted on railway and db is also hosted on railway
Brody
Brody2mo ago
may i ask why you showed a screenshot of you attempting to connect to the private url locally?
SSSuryaa
SSSuryaaOP2mo ago
do you get that error locally?
I mentioned that both are hosted on railway, because you asked this. sorry, english is not my first language
Solution
Brody
Brody2mo ago
your database and app are in different projects right? if so, they need to be in the same project
SSSuryaa
SSSuryaaOP2mo ago
yes, they are different projects. any way to combine those?
Brody
Brody2mo ago
it would be a manual process
SSSuryaa
SSSuryaaOP2mo ago
thanks, I'll look it up
Brody
Brody2mo ago
look what up?
SSSuryaa
SSSuryaaOP2mo ago
how to do this
Brody
Brody2mo ago
you already have, just do it in the correct project this time
SSSuryaa
SSSuryaaOP2mo ago
got it, thanks
Brody
Brody2mo ago
for the future, please read this docs page - https://docs.railway.app/overview/best-practices
Want results from more Discord servers?
Add your server