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
31 Replies
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.
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');
2 years ago
i left it on 3000
2 years ago
is that on general or only regarding the static ip option ?
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.
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
2 years ago
Btw, how to you specify which port to use in your express app?
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
2 years ago
same thing
2 years ago
What does your log say?
The + before process.env.PORT is a little weird.
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.
2 years ago
I did follow that
2 years ago
I did follow that
Alright, great. How do you enable static ip? I need to try it for myself :)
2 years ago
Ah right, it's only available in the us regions.
2 years ago
Its from settings
2 years ago
yes im using us
2 years ago
I'm gonna set up a little test app myself. Just hang on a bit.
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.
2 years ago
great to know ! , thanks for sharing
2 years ago
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?
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
2 years ago
any news ?
I have enable it again , same error
2 years ago
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?
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.
2 years ago
looks like its working now
2 years ago
What was the fix for this please? My apps are also not working if using a static IP. Fine without static.
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 • over 1 year ago