TCP Server Not Receiving Connections Despite Proper Configuration
rbarbosa
HOBBYOP

6 months ago

I have an AdonisJS application deployed on Railway with both HTTP and TCP services configured. The HTTP service works correctly, but the TCP server is not receiving incoming connections.

Current Setup:

- AdonisJS HTTP service running on port 8080 (working correctly)

- TCP server configured to listen on port 9090

- Public domain configured for HTTP traffic

- TCP proxy configured and enabled

- External TCP port: 34983 (as shown in Railway dashboard)

Issue:

The TCP server starts successfully and shows all expected logs.

However, when testing with netcat from external, no connection logs appear in the application, suggesting the TCP traffic isn't reaching the server.

Expected Behavior:

The TCP server should log incoming connections and data when external clients connect to the proxy endpoint.

Questions:

1. Is there additional configuration needed for TCP proxy to work?

2. You mentioned that is possible to use both HTTP and TCP: "Railway does support exposing both HTTP and TCP over public networking, in a single service." But then you also say "If you have a use case that requires exposing both HTTP and TCP over public networking, in one service, let us know." What does this means?

Environment:

- AdonisJS application

- TCP server listening on 0.0.0.0:9090

- Railway TCP proxy enabled

Solved

6 Replies

Railway
BOT

6 months ago

Our team is working on getting back to you as soon as possible. In the meantime, we've found the following might help you get unlocked faster:

If you find the answer from one of these, please let us know by solving the thread! Otherwise, we’ll be in touch.


brody
EMPLOYEE

6 months ago

Hello,

Since you had a PORT variable set, despite what your target port was set to in your TCP Proxy, the TCP Proxy will always point to what is set in PORT.

I have gone ahead and removed that for you, please redeploy.

Best,
Brody


Status changed to Awaiting User Response Railway 6 months ago


rbarbosa
HOBBYOP

6 months ago

Hey Brody,

Thanks for your quick reply.
If I remove the PORT variable, then both servers (HTTP and TCP) listen PORT 9090.
In the logs I get:
"started HTTP server on 0.0.0.0:9090

TCP server error: Error: listen EADDRINUSE: address already in use 0.0.0.0:9090
It seems that if I set to TCP proxy to 9090 it also sets the PORT to the same value.

That's why I explicit set the variable PORT to 8080.

Am I missing something?
Thanks
Rui


Status changed to Awaiting Railway Response Railway 6 months ago


brody
EMPLOYEE

6 months ago

You would need a different way to set the port the HTTP or TCP port that your application listens on, perhaps via command line arguments.


Status changed to Awaiting User Response Railway 6 months ago


rbarbosa
HOBBYOP

6 months ago

I'm sorry, I'm missing something.

In Railway settings, the TCP proxy port is set to 9090, and http to 8080 (see image).
In my app I set TCP for GPS_TCP_PORT env which I also set to be equal to 9090, and it listens http in ENV.PORT by default.
When running, the logs present that http is listening to 9090. This means that the TCP proxy port is setting (or overiding) the http port (to 9090), ie, PORT = 9090.
So, I'm already setting 2 different ports for my application to listen, but it seems that Railway can only have one port.
Can you explain more what is the real issue?
Thanks

Attachments


Status changed to Awaiting Railway Response Railway 6 months ago


What Brody is mentioning that you would need to start your server and your TCP connection via different logic than reading PORT - if your code is going to set the value via that, Railway will set the TCP port to that value.


Status changed to Awaiting User Response Railway 6 months ago


Railway
BOT

5 months ago

This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!

Status changed to Solved Railway 6 months ago


Loading...