Private networking (unable to access PORT)

a year ago

Goal

Dynamically access the port a service is listening on, via Railway reference variable.

Context

  • Both services are in the same environment/project

  • Both are listening on IPV6 host (::)

  • Both services are listening on the default PORT env var made available to them at runtime (8080)

Status

I've tried a reference variable as mentioned in this doc: https://docs.railway.com/guides/private-networking#using-reference-variables

It looks something like: http://${{service.RAILWAY_PRIVATE_DOMAIN}}:${{service.PORT}}

When logging this variable to console, the domain comes through, but the port is empty. My thinking was that the PORT variable used above would always be set to that which service is listening on - or at least, the one Railway automatically passes to the service at runtime.

I imagine that if I manually set a service variable, like PORT=8080, then this would work. But I was sort of hoping to let Railway do its thing and let these get set dynamically.

Apologies if this is made clear in the docs - it's possible I'm misunderstanding it.

Solved

3 Replies

a year ago

Hello,

That PORT variable is only injected at runtime and is not available in the dashboard, so you would indeed have to set it in the service variables.

The docs here definitely could be clearer, you are right.

Best,
Brody


Status changed to Awaiting User Response Railway about 1 year ago


a year ago

Understood - thank you! The docs are open to community contribution? I may just open a PR to add a note on this.


Status changed to Awaiting Railway Response Railway about 1 year ago


a year ago

They are! - https://github.com/railwayapp/docs

A PR for this would be much appreciated!


Status changed to Awaiting User Response Railway about 1 year ago


Status changed to Solved brody about 1 year ago


Loading...