3 months ago
I've got a nextjs app, that has a bunch of getstaticprops on build but I just get constant build failures about it cannot access it. The only way to solve it is to use public networking database url.
Error [PrismaClientInitializationError]:
Invalid prisma.song.findMany() invocation:
Can't reach database server at database.railway.internal:5432
Please make sure your database server is running at database.railway.internal:5432.
at async p (.next/server/chunks/ssr/_c9e176d6._.js:1:265) {clientVersion: '5.22.0',
errorCode: undefined
}
Pinned Solution
11 Replies
Status changed to Open Railway • 3 months ago
3 months ago
getStaticProps runs at build time (ie npm run build) - this is isolated in build so Railway doesn't know what your private network address is, it'll fail and fallback to the public one. This is a pretty standard workaround tbf and its gated by a strong password so not as risky as you might be thinking. The other option is to switch to server side props - https://nextjs.org/docs/pages/building-your-application/data-fetching/get-server-side-props
3 months ago
Where does it say this in the railway docs? I've read through them but found no mention of it, and get server side props is pointless as it's slower and I will have to have my db constantly up instead of serverless
3 months ago
i would assume it executed on client-side (.next/server/chunks/ssr/_c9e176d6._.js is looks like a bundled result of client-side code) and because private url means to be used by service in the same environment as your database service, you can't use it outside of railway services
mayori
i would assume it executed on client-side (`.next/server/chunks/ssr/_c9e176d6._.js` is looks like a bundled result of client-side code) and because private url means to be used by service in the same environment as your database service, you can't use it outside of railway services
3 months ago
ssr is server-side rendered
jozefbonnar
ssr is server-side rendered
3 months ago
does that error come from your deploy logs?
mayori
does that error come from your deploy logs?
3 months ago
Build logs, it fails getstaticprops on build, due to not being able to access the db through private networking
3 months ago
Services don’t have access to private networking during the build process.
0x5b62656e5d
Services don’t have access to private networking during the build process.
3 months ago
I understand but where are the docs that say this please?
3 months ago
0x5b62656e5d
Services don’t have access to private networking during the build process.
3 months ago
ohh, i didnt know about this, i think moving the build step to pre-deploy command will help, or just keep going with the database public url
Status changed to Solved 0x5b62656e5d • 3 months ago

