Server Error after using static ip
meshary-9
PROOP

2 years ago

Hey, my backend (Express) app was working fine.
After enabling static IP, it stopped working and showed  The application failed to respond (server error).

There are no error logs, however. and it has been like 30min

Solved

31 Replies

mikael-j-rich
PRO

2 years ago

Have you checked that the Express API is listening on the correct host? The Express app should listen to 0.0.0.0.


mikael-j-rich
PRO

2 years ago

https://expressjs.com/en/5x/api.html#app.listen

The correct way to start the Express app would be app.listen(PORT, '0.0.0.0');


meshary-9
PROOP

2 years ago

i left it on 3000


meshary-9
PROOP

2 years ago

is that on general or only regarding the static ip option ?


mikael-j-rich
PRO

2 years ago

3000 is the port, but the host also needs to be set. The host is normally localhost or 127.0.0.1. But Railway expects the host to be 0.0.0.0.

If 3000 is your port, have you set the PORT env variable to 3000?

It's general, not specific to static ip. But it could probably cause some issues with private ip.


meshary-9
PROOP

2 years ago

oh i understand you know

i have set the port only ( variable ) and it was working fine
i will try to set the host also as railway expects


mikael-j-rich
PRO

2 years ago

Btw, how to you specify which port to use in your express app?


meshary-9
PROOP

2 years ago

async function startServer() {
const app = express();

(await import("./loaders")).default({ app });

app
.listen(+process.env.PORT!, "0.0.0.0", () => {
console.log(Server running on port ${process.env.PORT});
})
.on("error", (err) => {
console.error(err);
process.exit(1);
});
}

i just added the host now and i will try


meshary-9
PROOP

2 years ago

same thing


mikael-j-rich
PRO

2 years ago

What does your log say?

The + before process.env.PORT is a little weird.


meshary-9
PROOP

2 years ago

its for typescript

logs are clean

Attachments


mikael-j-rich
PRO

2 years ago

Check this part of the docs: https://docs.railway.app/guides/fixing-common-errors

There is an example of how an express app should be started.


meshary-9
PROOP

2 years ago

I did follow that


mikael-j-rich
PRO

2 years ago

I did follow that

Alright, great. How do you enable static ip? I need to try it for myself :)


mikael-j-rich
PRO

2 years ago

Ah right, it's only available in the us regions.


meshary-9
PROOP

2 years ago

Its from settings


meshary-9
PROOP

2 years ago

yes im using us


mikael-j-rich
PRO

2 years ago

I'm gonna set up a little test app myself. Just hang on a bit.


mikael-j-rich
PRO

2 years ago

Seems to be an issue with Railway here, i get exactly the same as you. Have tried 3 different apps now and all is the same. When i enable static ip, they become unreachable.


meshary-9
PROOP

2 years ago

great to know ! , thanks for sharing


When you said that it was working before enabling static IP, did you change any configuration on your application? If you disable Static IP, does your application return working normally?


meshary-9
PROOP

2 years ago

no , i did not , i only added the host 0.0.0.0 to try and still not working

  • i just disabled the static ip and it worked again , my app works fine without static ip


meshary-9
PROOP

2 years ago

any news ?
I have enable it again , same error


This may be a bug, I am going to raise this issue to the developer- can you provide a repo and and a project Id so that we can conduct a investigation?


meshary-9
PROOP

2 years ago

project ID: 3f7d7937-ae24-435d-8826-11f9a355512b

For the repo, basically any app that uses a static IP will encounter the issue.

If the repo is necessary, I can ask my developer to create a reproduction repo.


That would be good for us, I have flagged it internally as well.


meshary-9
PROOP

2 years ago

looks like its working now


Let us know if you see the issue pop up again.


jpivac
PRO

2 years ago

What was the fix for this please? My apps are also not working if using a static IP. Fine without static.


meshary-9
PROOP

2 years ago

What was the fix for this please? My apps are also not working if using a static IP. Fine without static.

its a bug from railway it get fixed now all good


2 years ago

There was a bug that affected containers placed on certain host machines, which is now patched. If you experienced this issue, re-deploying with Static IPs enabled should work now.


Status changed to Solved Railway almost 2 years ago


Loading...