Confusion about RAILWAY_PRIVATE_DOMAIN
hazamashoken
HOBBYOP

2 years ago

Project ID: 358600cb-32ed-4c25-a1a0-5e28c7a14ed9

I have NextJS frontend that need to connect to a Django backend service. I wonder if it is possible to connect via RAILWAY_PRIVATE_DOMAIN somehow or am i confusing myself somewhere ?

Solved

19 Replies

hazamashoken
HOBBYOP

2 years ago

All API call are in server action so it run on server, so it should have access to RAILWAY_PRIVATE_DOMAIN right ?


2 years ago

Remember, your frontend's code will be running on a different computer in a different network so it won't be able to connect via the private network to the backend


hazamashoken
HOBBYOP

2 years ago

so what's the use case of RAILWAY_PRIVATE_DOMAIN ?


2 years ago

it's meant for backend services to communicate among each other


2 years ago

using the private network for backend services to communicate has a lot of benefits, for example:

  • Not exposed publicly, meaning better security
  • Faster communication
  • No egress costs

hazamashoken
HOBBYOP

2 years ago

that's what I also understand so it should work in my case right ? since NextJS server action is call in the server (backend) so it should be able to communicate with django (backend) right ?


hazamashoken
HOBBYOP

2 years ago

but when I try to use RAILWAY_PRIVATE_DOMAIN in http or https format, it doesn't work. It only work when I use RAILWAY_PUBLIC_DOMAIN ?


2 years ago

ohh, if you're running it as a server action then yea sorry for my confusion


2 years ago

make sure you're also specifying the port when you're connecting to the private domain (unless it's running on port 80)


hazamashoken
HOBBYOP

2 years ago

ohhh


2 years ago

a service (foo) running on port 3000's private connection would look like this:

  • http://foo.railway.internal:3000

hazamashoken
HOBBYOP

2 years ago

so RAILWAY_PRIVATE_DOMAIN does not forward port like RAILWAY_PUBLIC_DOMAIN right ?


hazamashoken
HOBBYOP

2 years ago

i see now, will make change now


2 years ago

yea, pretty much

HTTP uses port 80 by default and HTTPS uses port 443 by default

on the public domain Railway's proxy automatically bridges port 443 to your service's port

but on the private domain there is no proxy like that so you have to specify the port if it's not running on the default port


hazamashoken
HOBBYOP

2 years ago

very clear now thank you


2 years ago

awesome, glad I could help 🙂


hazamashoken
HOBBYOP

2 years ago

alright it work now. but to add a bit more RAILWAY_PRIVATE_DOMAIN use ipv6 so for it to work the django backend just need to also listen to ipv6.


2 years ago

oh true, glad you got it working!


2 years ago

!s


Status changed to Solved dev over 1 year ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...