How do you expose a port?
I have a service in Railway that runs a Java server bound to port
5266
. I want to expose that publicly so anybody can access the server. So I added the env variable PORT
in the settings of that service. But when I do the telnet
test to make the TCP/IP connection, nothing is listening on it.7 Replies
Project ID:
1f1e865e-cb58-46db-b427-0b47e5dad0c1
1f1e865e-cb58-46db-b427-0b47e5dad0c1
you can only expose either a single tcp port or a single http port, with http you can only access the app over https and port 443
How do I expose the port
443
? Do I set the PORT
env variable to be 443
?I did the following
- Set the PORT env variable to
443
- Bound the server to port 443
- Go to the browser and tried access one of the GET endpoints, and I get this.
Which makes me think probably the server is not exposed correctly.![No description](https://cdn.answeroverflow.com/1167147621626945607/Screenshot_2023-10-26_at_21.06.56.png)
The server starts up with SSL properly in localhost. I can access the server with
https
locally.railway automatically generates a PORT environment variable for you, you should not be setting your own, you only need to listen on it.
to access your app externally from https you need to be only starting an http server, you cant start an https server, railway handles https for you