V2 runtime issue when setting port as 443

pepijnPRO

a year ago

I just created a new instance with automatically the V2 runtime set and here the builds do not deploy and I get the error message:
Error: listen EACCES: permission denied 0.0.0.0:443

When I switch the runtime back to Legacy, it works and deploys correctly.
If I try to change the port to something else, i.e. 3000, with the V2 runtime the healthcheck does not work. It is a NextJs project.

0 Replies

pepijnPRO

a year ago

a0f3572b-295e-4a43-b776-ce352a4d0980


a year ago

please use a non privileged port.

as for the health check failing, there's a bug with the v2 runtime where your app needs to listen on ipv6 to pass a health check, if I'm not mistaken you should be able to set a HOSTNAME variable to :: or change your start script to add a -H :: flag to next start, but I'm not sure if you are using next start so try the variable first


pepijnPRO

a year ago

Thanks for the info


pepijnPRO

a year ago

@Brody I used port 443 so the x-forwarded-port would be passed correctly, but now it thinks this is port 3000


pepijnPRO

a year ago

So the above solution works, but the I18n plugin I use, checks the x-forwarded-port to apply certain redirects



a year ago

railway does not set a x-forwarded-port header


a year ago

instead of setting your PORT to 443, this is the correct solution


pepijnPRO

a year ago

Hmm okay, hardcoding it for the port can be fine. But the same issue applies also for X-Forwarded-For I would think and then the originating client IP is lost.


a year ago


a year ago

pseudo code
if X-Forwarded-Proto == https { X-Forwarded-Port = 443 }


pepijnPRO

a year ago

Check, thanks


a year ago

A fix has been rolled out for this


pepijnPRO

a year ago

What does the fix entail exactly?


a year ago

I assume it would allow you to bind to a non-privileged port given the context of this thread


a year ago

You can now use port 443


a year ago

fwiw I still think binding to a non-privileged port is the more correct option