Confusion about RAILWAY_PRIVATE_DOMAIN
hazamashoken
HOBBYOP

a year 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 RAILWAYPRIVATEDOMAIN somehow or am i confusing myself somewhere ?

Solved

19 Replies

hazamashoken
HOBBYOP

a year ago

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


dev
MODERATOR

a year 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

a year ago

so what's the use case of RAILWAYPRIVATEDOMAIN ?


dev
MODERATOR

a year ago

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


dev
MODERATOR

a year 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

a year 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

a year ago

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


dev
MODERATOR

a year ago

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


dev
MODERATOR

a year 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

a year ago

ohhh


dev
MODERATOR

a year ago

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

  • [http://foo.railway.internal:3000](http://foo.railway.internal:3000)


hazamashoken
HOBBYOP

a year ago

so RAILWAYPRIVATEDOMAIN does not forward port like RAILWAYPUBLICDOMAIN right ?


hazamashoken
HOBBYOP

a year ago

i see now, will make change now


dev
MODERATOR

a year 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

a year ago

very clear now thank you


dev
MODERATOR

a year ago

awesome, glad I could help 🙂


hazamashoken
HOBBYOP

a year ago

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


dev
MODERATOR

a year ago

oh true, glad you got it working!


dev
MODERATOR

a year ago

!s


Status changed to Solved dev about 1 year ago


Loading...