8 months ago
Hi, friends! I'm deploying a new app on railway, I've followed the guides without problem.
The build was successful, the application is running, but I can't access this, because I'm getting a 502 status code.
https://docs.railway.app/guides/fixing-common-errors
I've followed this guide but didn't solved my problem.
I'm already using the PORT that railway provides and the host is set to 0.0.0.0
Am I missing something?
0 Replies
My public route is this:
niki-backend-homolog.up.railway.app
8 months ago
hey, send your app.listen
.
I also use nest and have no problems, pretty weird.
8 months ago
I don't even need the 0.0.0.0, maybe you could give it a try?
but anyway, the port env would work without any problems.
8 months ago
weird, are u using fastify or express?
8 months ago
hmmm im using express so it might have a difference
8 months ago
I guess I've an application where I used fastify but anyway the port env should be working alright so I guess there's no need to do something about it
i see a question here with the same problem, probably?
https://help.railway.app/questions/my-backend-is-launched-without-probleme-9970071f
8 months ago
couldnt find any other issue related to fastify and 502
8 months ago
yep its alright
8 months ago
the private networking isn't available at build unfortunately.
in my case I do the migration on the start script
8 months ago
by using public url you'll be charged more by bandwidth.
I don't know how much you would but I'm pretty sure it would be cheap
8 months ago
If you're sure of that then ok
8 months ago
but tbh I would just move the migration script to the start command
8 months ago
yep, are u using prisma?
8 months ago
ah typeorm
8 months ago
yep but my backend contains a healthcheck
if yours dont then it would just fail
8 months ago
but its pretty simple to setup one
https://docs.nestjs.com/recipes/terminus#setting-up-a-healthcheck
8 months ago
this is my script with prisma:
"start": "prisma generate --no-hints && prisma migrate deploy && node dist/src/main",
8 months ago
Railway will hold the deployment of your application until its actually reachable by doing an HTTP ping to a /health
endpoint
8 months ago
you've to configure it in the service settings
8 months ago
trying to restart? you mean an infinite loop of fail restart?
8 months ago
nope, thats another setting
8 months ago
8 months ago
go to your service settings and scroll down until you see that
will this be enough?
@Controller('health')
export class HealthController {
@Get()
healthCheck() {
return { ok: true };
}
}
8 months ago
yep it should be alright
8 months ago
nestjs also offers the option to check your database and other external services but thats optional, that health controller will work
imma see them later, if my db is down, the routes will be the smaller problem lmao
8 months ago
makes sense <:kekw:788259314607325204>
ive added the route, but its not working, probably because previous deploy was not with port
8 months ago
wdym by not working? 502 or build not going through?
8 months ago
no port yet? Railway should just do a load balance so both of the deploys will contain the port
8 months ago
yep, i'll see if I can get my fastify app to see what I did but it just worked 💀
8 months ago
yep it just works 💀
8 months ago
I use to validate my env variables and then import it elsewhere
8 months ago
yes
8 months ago
you mean in terms of pricing?
8 months ago
well Railway's memory pricing is not that cheap but if your just using for cache it should be alright
8 months ago
I used to host a bullmq queue with at least 16k per minute inserts and it was pretty cheap IMO
8 months ago
great!
8 months ago
boa noite!