PORT
variable not created, magic port detection not working

mattcarusoHOBBY

a year ago

I'm running a Flask server with gunicorn. My private networking is working correctly, but I can't get public networking to work.

When I generated a domain, it didn't create a PORT variable for my service. When I defined the port my service was listening to as the PORT variable, it also didn't work. Lastly, the magic port detection didn't give me any prompts, so it doesn't seem to be aware that my service is listening.

I'm trying to listen on :5000 publicly and :8080 privately.
unicorn wsgi:app --bind 0.0.0.0:5000 --bind '[::]:8080'

The server seems to be configured correctly, as it prints this during deploy:
[2024-05-03 03:09:22 +0000] [9] [INFO] Listening at: [http://0.0.0.0:5000,http://[::]:8080](http://0.0.0.0:5000,http://[::]:8080) (9)

3 Replies

a year ago

magic port detection not working

Railway does not have "magic port detection" But please tell me why you think it does?

I'm trying to listen on :5000 publicly and :8080 privately

May I aks why? gunicorn does support dual stack binding just fine.

Simply change your start command to gunicorn wsgi:app and then set a fixed PORT service variable.


mattcarusoHOBBY

a year ago

Magic port is described here and also described as "automated prompt" here.

I'm trying to listen on two different ports as an experiment. I wasn't sure if the [::]:8080 notation would listen on 0.0.0.0 as Railway requires, so I tried binding 0.0.0.0:5000 just to be absolutely sure during my troubleshooting.

I can't just do gunicorn wsgi:app because it doesn't expose the IPv6 address for private networking.


a year ago

Interesting, they definitely don't do that anymore.

And you're right, the start command you would want would be -

gunicorn wsgi:app --bind [::]${PORT}

`PORT` variable not created, magic port detection not working - Railway Help Station