a month 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 • 29 days ago
a month 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
a month 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
a month 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
mayoriii
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
a month ago
ssr is server-side rendered
jozefbonnar
ssr is server-side rendered
a month ago
does that error come from your deploy logs?
mayoriii
does that error come from your deploy logs?
a month ago
Build logs, it fails getstaticprops on build, due to not being able to access the db through private networking
a month 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.
a month ago
I understand but where are the docs that say this please?
a month ago
0x5b62656e5d
Services don’t have access to private networking during the build process.
a month 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 • 29 days ago

