9 months ago
I’ve deployed a full-stack application on Railway consisting of the following:
A Convex backend
A Next.js 15 frontend
A Node.js backend API
All three services deploy successfully and work individually:
Convex dashboard loads properly via a custom domain.
Next.js app and Node backend are reachable via custom domains.
All environment variables are configured in the Railway dashboard.
However, I’m running into issues with internal service-to-service communication post-deployment:
Environment variables appear undefined at runtime
NEXT_PUBLIC_CONVEX_URLis defined in the Railway dashboard under the frontend service.However, at runtime in the browser, it is
undefined, even though it’s prefixed correctly.It references a private internal domain of the Convex service.
I’ve confirmed the variable exists before deployment, and it’s added before the build step.
Internal requests between services fail
The Node.js backend tries to connect to Convex or respond to frontend calls, but fails.
I've tried sending a request from Postman using a public custom domain. I've received the following error.
Example error:
[cause]: Error: connect ECONNREFUSED fd12:fe40:....at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1611:16) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: 'fd12:fe40:9a...',
port: 443
}
}
Custom domains don’t solve internal connectivity
I’ve mapped custom domains for the frontend and backend.
External traffic works (I can hit the routes via browser or Postman).
Internal service-to-service requests still fail or time out.
What I've tried
1. Tried binding servers to both 0.0.0.0 and ::,as the private network is an IPv6 only network.
Questions:
How to ensure internal networking between services works on Railway?
Why is
NEXT_PUBLIC_CONVEX_URLundefined at runtime, even when it exists in Railway variables?What’s the recommended way to structure internal service-to-service communication for multi-service setups (Convex + Node + Next) on Railway?
4 Replies
9 months ago
How are you trying to get the variable? Is there a Dockerfile involed?
Status changed to Awaiting User Response Railway • 9 months ago
9 months ago
I'm using a custom Docker file for my Next.js 15 frontend and Node backend.
The Next.js app exposes port 3000, and the Node server uses port 8080. I assumed Railway would inject environment variables automatically, and I've added them in the Railway dashboard for each service.
Status changed to Awaiting Railway Response Railway • 9 months ago
9 months ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open chandrika • 9 months ago
8 months ago
You will need to pass the variables in your Dockerfile https://docs.railway.com/guides/dockerfiles#using-variables-at-build-time
8 months ago
How to ensure internal networking between services works on Railway?
It is IPv6 you can ensure it is working - https://docs.railway.com/reference/private-networking#internal-dns
Here is their documentation on it. If you follow, you should be ble to connect s long as your app support IPv6