R
Railway•14mo ago
BenIsenstein

Struggling to establish a connection through private networking

project id 8b67ba4d-ba67-4f38-97ef-8caab4e245fe I have two services both running express JS. I have added a '::' to the
app.listen(PORT, '::', ...)
app.listen(PORT, '::', ...)
call in order to bind to IPv6 ports. The service trying to establish the connection is enabled for public and private. The other service is private only, and consistently refuses the connection.
port: 80,

address: '127.0.0.1',

syscall: 'connect',

code: 'ECONNREFUSED',

errno: -111,

method: 'post',
url: 'image-service.railway.internal/api/upload',
data: '{"filePath":"Typeform/2023_9_30/Getting started with Typeform","html":"<!DOCTYPE h...
port: 80,

address: '127.0.0.1',

syscall: 'connect',

code: 'ECONNREFUSED',

errno: -111,

method: 'post',
url: 'image-service.railway.internal/api/upload',
data: '{"filePath":"Typeform/2023_9_30/Getting started with Typeform","html":"<!DOCTYPE h...
14 Replies
Percy
Percy•14mo ago
Project ID: 8b67ba4d-ba67-4f38-97ef-8caab4e245fe
Brody
Brody•14mo ago
you'd need to use http and specific a port in the url when calling the private network
MantisInABox
MantisInABox•14mo ago
Your URL for internal calls should include the port
Brody
Brody•14mo ago
😇
BenIsenstein
BenIsensteinOP•14mo ago
Got it is the PORT env var accessible through template functions? For every service in the project? Is this how I'm meant to share which port to point at to all my services?
Brody
Brody•14mo ago
if you sent one yourself, yes, the auto generated one, no and you would want to set one yourself so there's no random ports in use
BenIsenstein
BenIsensteinOP•14mo ago
So what's the recommended way of giving each service on the internal network knowledge of eachother's ports? Manually setting them eh?
Brody
Brody•14mo ago
set the port on the service then you can reference it in another service
BenIsenstein
BenIsensteinOP•14mo ago
Yeah jsut read that the auto-generated one is for public networking (Y) "If you wish to open a service that has a public, you can use the PORT environment variable to specify the public port. This will allow Railway to route traffic to the public port."
Brody
Brody•14mo ago
I wouldn't say it's strictly for public networking as your app would still need to listen on PORT for healthchecks, and those are done internally
BenIsenstein
BenIsensteinOP•14mo ago
hmm I'm about to set the PORT for these two services for private network I've never chosen ports before, is there any recommended one? What's the limit to the port numbers?
Brody
Brody•14mo ago
the same limit as the highest tcp port number, but I'd recommend common non privileged ports like 3000, 4000, 8000, 8080
BenIsenstein
BenIsensteinOP•14mo ago
Here's what chatGPT says
Selecting a port number for IPv6 binding in a networked application follows similar principles to choosing a port for IPv4. Port numbers range from 0 to 65535 and are categorized into well-known ports (0-1023), registered ports (1024-49151), and dynamic/private ports (49152-65535).

Guidelines for Choosing a Port Number:
Avoid Well-Known Ports: Ports below 1024 are generally reserved for well-known services (e.g., HTTP on port 80, HTTPS on port 443). Unless you are implementing one of these services, avoid using these port numbers.

Consult Registered Ports List: Ports from 1024 to 49151 are often registered for particular services. Check the IANA Service Name and Transport Protocol Port Number Registry to ensure the port you are considering is not already registered for a different service.

Dynamic/Private Ports: If your application is not a well-known or widely distributed service, consider using a dynamic/private port (49152-65535). These are not officially registered and are generally considered safe for private or internal use.

Check for Conflicts: Before settling on a port, verify that it's not already being used on the system where the application will run. Use commands like netstat or lsof on Unix-like systems, or Get-NetTCPConnection in PowerShell on Windows, to list active network connections.

Make it Configurable: If possible, make the port number configurable so that if a conflict arises in the future, it can be easily changed without modifying the codebase.

Adherence to Company or Project Guidelines: In an enterprise environment or an open-source project, there may be specific rules or guidelines about picking port numbers. Make sure to consult these.
Selecting a port number for IPv6 binding in a networked application follows similar principles to choosing a port for IPv4. Port numbers range from 0 to 65535 and are categorized into well-known ports (0-1023), registered ports (1024-49151), and dynamic/private ports (49152-65535).

Guidelines for Choosing a Port Number:
Avoid Well-Known Ports: Ports below 1024 are generally reserved for well-known services (e.g., HTTP on port 80, HTTPS on port 443). Unless you are implementing one of these services, avoid using these port numbers.

Consult Registered Ports List: Ports from 1024 to 49151 are often registered for particular services. Check the IANA Service Name and Transport Protocol Port Number Registry to ensure the port you are considering is not already registered for a different service.

Dynamic/Private Ports: If your application is not a well-known or widely distributed service, consider using a dynamic/private port (49152-65535). These are not officially registered and are generally considered safe for private or internal use.

Check for Conflicts: Before settling on a port, verify that it's not already being used on the system where the application will run. Use commands like netstat or lsof on Unix-like systems, or Get-NetTCPConnection in PowerShell on Windows, to list active network connections.

Make it Configurable: If possible, make the port number configurable so that if a conflict arises in the future, it can be easily changed without modifying the codebase.

Adherence to Company or Project Guidelines: In an enterprise environment or an open-source project, there may be specific rules or guidelines about picking port numbers. Make sure to consult these.
Brody
Brody•14mo ago
far too many words everything I do is port 3000, and during my time on this server it's the most widely used
Want results from more Discord servers?
Add your server