R
Railwayβ€’2y ago
Krishang

Application Not working

It's my first time using railway, and I followed a video, but mine is not working, I followed the exact steps. In the deploy logs I see my messages for successfull connections to server and database (server connected and database connected). But when I access the genereated link, I get "Application failed to respond". What might be the cause of the problem?
19 Replies
Percy
Percyβ€’2y ago
Project ID: 6f38d8e1-4d25-4b98-92ad-bbd35b159999
Krishang
KrishangOPβ€’2y ago
6f38d8e1-4d25-4b98-92ad-bbd35b159999
Krishang
KrishangOPβ€’2y ago
// Use PORT provided in environment or default to 3000
const port = process.env.PORT || 3000;

// Listen on `port` and 0.0.0.0
app.listen(port, "0.0.0.0", function () {
// ...
});
// Use PORT provided in environment or default to 3000
const port = process.env.PORT || 3000;

// Listen on `port` and 0.0.0.0
app.listen(port, "0.0.0.0", function () {
// ...
});
This is provided as the solution for this problem.. But my question is, if I update my code with app.listen(port, "0.0.0.0" ... ) shouldn't it automatically start on the port variable defined earlier?
luna
lunaβ€’2y ago
shouldn't it automatically start on the port variable defined earlier?
What do you mean by this?
LaCrak27
LaCrak27β€’2y ago
proccess.env.PORT that's how you access env variables
Krishang
KrishangOPβ€’2y ago
When defining the port variable, we give it 2 choices right? a number.. 5000 in my case, or process.env.PORT which is an env variable, since they are predefined, the app will always use them, instead of "0.0.0.0"
luna
lunaβ€’2y ago
0.0.0.0 is the host
LaCrak27
LaCrak27β€’2y ago
app.listen(process.env.PORT, () => {
console.log(`SSAPI active, listening on port ${process.env.PORT}.`)
})
app.listen(process.env.PORT, () => {
console.log(`SSAPI active, listening on port ${process.env.PORT}.`)
})
luna
lunaβ€’2y ago
the port is seperate from that.
LaCrak27
LaCrak27β€’2y ago
i just do this lmao 0.0.0.0 is the ip adress, and the port is something completely unrelated
Krishang
KrishangOPβ€’2y ago
ohh πŸ˜…
LaCrak27
LaCrak27β€’2y ago
ye, dw
Krishang
KrishangOPβ€’2y ago
A little dumb of me, but it's working now.. I looked closely and it was a matter of preference
LaCrak27
LaCrak27β€’2y ago
perfect then
Krishang
KrishangOPβ€’2y ago
The docs say I should prioritize the env variable And not the hard coded port number
LaCrak27
LaCrak27β€’2y ago
yeah
Krishang
KrishangOPβ€’2y ago
It's working now! Thanks for all the time and help!!
LaCrak27
LaCrak27β€’2y ago
npnp gl with your app
Want results from more Discord servers?
Add your server