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

36 messages · Page 1 of 1 (latest)

dark kayak
#

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 😦

candid fossilBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

heavy sparrowBOT
#

Project ID: 5cf263e7-05ea-40b5-9d62-95471f49d9cf

dark kayak
#

my project id: 5cf263e7-05ea-40b5-9d62-95471f49d9cf

raw onyx
dark kayak
#

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

raw onyx
#

what port does the railway logs say your app is listening on

#

normally you'd log that out as confirmation the server started

dark kayak
#

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

raw onyx
#

your app should be listening on the environment variable PORT

dark kayak
#

i have done that, and i get the same 503

#

unbelievable but i could fix it doing this

#

thanks

raw onyx
# dark kayak

in this screenshot your app tells me that it was not setup to listen on the environment variable PORT

dark kayak
#

yeah, you're right, since the beginning we just run it by default

#

this is my main

raw onyx
#

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

dark kayak
#

yeah i know i have been fighting with this like 2 days

raw onyx
#

lol im sure you could just google what i have told you to do

dark kayak
#

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

raw onyx
#

with that code, it works?

dark kayak
#

Yeah it works

raw onyx
#

that's great!

dark kayak
#

Why? Idk but it works haha

raw onyx
#

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

dark kayak
#

Oh, i see
Thanks u saved me

raw onyx
#

I will look into adding a code snippet to the docs page for springboot

dark kayak
#

It would be great!

raw onyx
#

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

dark kayak
#

Ok, if my code is useful i feel helpful haha