How do I connect to one service to another using the internal network?
davehowson
PROOP

a year ago

I'm trying to connect from my Astro application to my Next server via the internal network through network variables, but I keep getting

Failed to parse URL from kingdom-events.railway.internal/api/attendees

ERR_INVALID_URL

Is there anything I'm missing?

Solved

6 Replies

davehowson
PROOP

a year ago

This is how I have specified my ENV variable

${{kingdom-events.RAILWAY_PRIVATE_DOMAIN}}/api


a year ago

Heya, it seems you're just missing the https:// in your env var. You could make it work like so: https://${{kingdom-events.RAILWAY_PRIVATE_DOMAIN}}/api . RAILWAY_PRIVATE_DOMAIN only gives you the domain w/o any protocol (so not a URL).

hope this helps !

Best,

Nico


Status changed to Awaiting User Response Railway over 1 year ago


nico

Heya, it seems you're just missing the `https://` in your env var. You could make it work like so: `https://${{kingdom-events.RAILWAY_PRIVATE_DOMAIN}}/api` . `RAILWAY_PRIVATE_DOMAIN` only gives you the domain w/o any protocol (so not a URL). hope this helps ! Best, Nico

davehowson
PROOP

a year ago

Makes sense. But when I changed it to https://${{kingdom-events.RAILWAY_PRIVATE_DOMAIN}}/api

I get

cause: Error: connect ECONNREFUSED fd12:[redacted]:443

Jan 28 09:12:41

at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)

Jan 28 09:12:41

at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:128:17) {

Jan 28 09:12:41

errno: -111,

Jan 28 09:12:41

code: 'ECONNREFUSED',

Jan 28 09:12:41

syscall: 'connect',

Jan 28 09:12:41

address: 'fd12:[redacted]:ffd6',

Jan 28 09:12:41

port: 443


Status changed to Awaiting Railway Response Railway over 1 year ago


davehowson

Makes sense. But when I changed it to `https://${{kingdom-events.RAILWAY_PRIVATE_DOMAIN}}/api` I get cause: Error: connect ECONNREFUSED fd12:\[redacted\]:443 [Jan 28 09:12:41](https://railway.com/project/79565545-7fe2-4bd0-b982-558fdfa6b5e6/logs?environmentId=67b827e2-8d12-4610-a97e-f00c78d99c1e&filter=%40deployment%3A1e4d8bde-a526-4e94-86b4-e348121d897f+-%40replica%3Ade728814-d42f-44d8-8533-470ae16bd107&context=2025-01-28T03%3A42%3A41.722978954Z) at TCPConnectWrap.afterConnect \[as oncomplete\] (node:net:1555:16) [Jan 28 09:12:41](https://railway.com/project/79565545-7fe2-4bd0-b982-558fdfa6b5e6/logs?environmentId=67b827e2-8d12-4610-a97e-f00c78d99c1e&filter=%40deployment%3A1e4d8bde-a526-4e94-86b4-e348121d897f+-%40replica%3Ade728814-d42f-44d8-8533-470ae16bd107&context=2025-01-28T03%3A42%3A41.722994548Z) at TCPConnectWrap.callbackTrampoline (node:internal/async\_hooks:128:17) { [Jan 28 09:12:41](https://railway.com/project/79565545-7fe2-4bd0-b982-558fdfa6b5e6/logs?environmentId=67b827e2-8d12-4610-a97e-f00c78d99c1e&filter=%40deployment%3A1e4d8bde-a526-4e94-86b4-e348121d897f+-%40replica%3Ade728814-d42f-44d8-8533-470ae16bd107&context=2025-01-28T03%3A42%3A41.723007770Z) errno: -111, [Jan 28 09:12:41](https://railway.com/project/79565545-7fe2-4bd0-b982-558fdfa6b5e6/logs?environmentId=67b827e2-8d12-4610-a97e-f00c78d99c1e&filter=%40deployment%3A1e4d8bde-a526-4e94-86b4-e348121d897f+-%40replica%3Ade728814-d42f-44d8-8533-470ae16bd107&context=2025-01-28T03%3A42%3A41.723022466Z) code: 'ECONNREFUSED', [Jan 28 09:12:41](https://railway.com/project/79565545-7fe2-4bd0-b982-558fdfa6b5e6/logs?environmentId=67b827e2-8d12-4610-a97e-f00c78d99c1e&filter=%40deployment%3A1e4d8bde-a526-4e94-86b4-e348121d897f+-%40replica%3Ade728814-d42f-44d8-8533-470ae16bd107&context=2025-01-28T03%3A42%3A41.723035699Z) syscall: 'connect', [Jan 28 09:12:41](https://railway.com/project/79565545-7fe2-4bd0-b982-558fdfa6b5e6/logs?environmentId=67b827e2-8d12-4610-a97e-f00c78d99c1e&filter=%40deployment%3A1e4d8bde-a526-4e94-86b4-e348121d897f+-%40replica%3Ade728814-d42f-44d8-8533-470ae16bd107&context=2025-01-28T03%3A42%3A41.723053627Z) address: 'fd12:\[redacted\]:ffd6', [Jan 28 09:12:41](https://railway.com/project/79565545-7fe2-4bd0-b982-558fdfa6b5e6/logs?environmentId=67b827e2-8d12-4610-a97e-f00c78d99c1e&filter=%40deployment%3A1e4d8bde-a526-4e94-86b4-e348121d897f+-%40replica%3Ade728814-d42f-44d8-8533-470ae16bd107&context=2025-01-28T03%3A42%3A41.723065996Z) port: 443

davehowson
PROOP

a year ago

I changed my next projects start script to this following docs as well

next start --hostname :: --port ${PORT-3000}"

But still getting connection refused


davehowson

I changed my next projects start script to this following docs as well ```json next start --hostname :: --port ${PORT-3000}" ``` But still getting connection refused

davehowson
PROOP

a year ago

Not sure if I should specify the port in my FE, but I did so

https://${{kingdom-events.RAILWAY_PRIVATE_DOMAIN}}:8080/api

and now I get

cause: [Error: 40EC5784F77F0000:error:0A0000C6:SSL routines:tls_get_more_records:packet length too long:ssl/record/methods/tls_common.c:662:

Jan 28 09:41:06

] {

Jan 28 09:41:06

library: 'SSL routines',

Jan 28 09:41:06

reason: 'packet length too long',

Jan 28 09:41:06

code: 'ERR_SSL_PACKET_LENGTH_TOO_LONG'

Jan 28 09:41:06

}


davehowson
PROOP

a year ago

Removed https and it works 😁

http://${{kingdom-events.RAILWAY_PRIVATE_DOMAIN}}:8080/api - is the right way. Thank you


Status changed to Solved brody over 1 year ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...