Error 503 a la hora de hacer peticion / 503 error doing a petition

Hola a todos, estoy tratando de desplegar una api hecha en spring boot con java y gradle, ya he desplegado una base de datos postgresql y cuando trabajo localmente, logro conectarme a esa base de datos, ahora bien, hago el despliegue de mi api y en commands run pongo el siguiente: java -jar build/libs/TopTrend-0.0.1.jar (TopTrend es el nombre de mi app) en los logs no tengo ningun error y mis variables de entorno tengo justamente las mismas que en mi api local, pero cuando hago una petición con el link que railway me da, obtengo un error 503 y no entiendo porque. Ayuda por favor 😦 Hi everyone, i'm trying to deploy an api using spring boot with java and gradle, i have already deploy a postgresql, working locally my spring boot api can connect to that database, now, when i deploy mu spring boot api in commands run i type this : java -jar build/libs/TopTrend-0.0.1.jar (TopTrend is my app name) and logs don't give me any error, i use the same ENV i use locally, i use in railway, but when i do a petition i get a 503 error and i don't understand why. I really need help 😦
30 Replies
Percy
Percy13mo ago
Project ID: 5cf263e7-05ea-40b5-9d62-95471f49d9cf
rodrigosblack
rodrigosblack13mo ago
my project id: 5cf263e7-05ea-40b5-9d62-95471f49d9cf
Brody
Brody13mo ago
rodrigosblack
rodrigosblack13mo ago
believe me, i have already try what the documentation says, i have tried with, PORT and HOST, also with server.port and server.addres (last 2 because spring request it like that) and didn't work :c
Brody
Brody13mo ago
what port does the railway logs say your app is listening on normally you'd log that out as confirmation the server started
rodrigosblack
rodrigosblack13mo ago
logs tell me in port 8080 (but this is by default in spring) when i try with differents ports like 80, 463, also 6528, but answer is the same
Brody
Brody13mo ago
your app should be listening on the environment variable PORT
rodrigosblack
rodrigosblack13mo ago
i have done that, and i get the same 503
rodrigosblack
rodrigosblack13mo ago
rodrigosblack
rodrigosblack13mo ago
unbelievable but i could fix it doing this
rodrigosblack
rodrigosblack13mo ago
thanks
Brody
Brody13mo ago
in this screenshot your app tells me that it was not setup to listen on the environment variable PORT
rodrigosblack
rodrigosblack13mo ago
yeah, you're right, since the beginning we just run it by default this is my main
rodrigosblack
rodrigosblack13mo ago
Brody
Brody13mo ago
that docs page really should have a code example for springboot, since you have still not set up your app to listen on the environment variable PORT
rodrigosblack
rodrigosblack13mo ago
yeah i know i have been fighting with this like 2 cryingman
Brody
Brody13mo ago
lol im sure you could just google what i have told you to do
rodrigosblack
rodrigosblack13mo ago
At the end I could fix it, if u wouldn't open my mind about PORT i think i still would be suffering haha
rodrigosblack
rodrigosblack13mo ago
and i made this change
Brody
Brody13mo ago
with that code, it works?
rodrigosblack
rodrigosblack13mo ago
Yeah it works
Brody
Brody13mo ago
that's great!
rodrigosblack
rodrigosblack13mo ago
Why? Idk but it works haha
Brody
Brody13mo ago
because railway assigns the PORT variable for you, and if you don't listen on it, railway won't know how to sent traffic to your app
rodrigosblack
rodrigosblack13mo ago
Oh, i see Thanks u saved cryingman
Brody
Brody13mo ago
I will look into adding a code snippet to the docs page for springboot
rodrigosblack
rodrigosblack13mo ago
It would be great!
Brody
Brody13mo ago
never touched a line of java in my life, so I'll see how that goes I'd probably just use your code minus the password thing
rodrigosblack
rodrigosblack13mo ago
Ok, if my code is useful i feel helpful haha
Brody
Brody13mo ago
you definitely are!