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
Project ID:
5cf263e7-05ea-40b5-9d62-95471f49d9cf
my project id: 5cf263e7-05ea-40b5-9d62-95471f49d9cf
please read over this docs page
https://docs.railway.app/troubleshoot/fixing-common-errors
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
what port does the railway logs say your app is listening on
normally you'd log that out as confirmation the server started
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
your app should be listening on the environment variable PORT
i have done that, and i get the same 503
unbelievable but i could fix it doing this
thanks
in this screenshot your app tells me that it was not setup to listen on the environment variable PORT
yeah, you're right, since the beginning we just run it by default
this is my main
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
yeah i know i have been fighting with this like 2
lol im sure you could just google what i have told you to do
At the end I could fix it, if u wouldn't open my mind about PORT i think i still would be suffering haha
and i made this change
with that code, it works?
Yeah it works
that's great!
Why? Idk but it works haha
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
Oh, i see
Thanks u saved
I will look into adding a code snippet to the docs page for springboot
It would be great!
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
Ok, if my code is useful i feel helpful haha
you definitely are!