2 years 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?
95 Replies
My public route is this:
niki-backend-homolog.up.railway.app
2 years ago
hey, send your app.listen.
I also use nest and have no problems, pretty weird.
2 years 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.

2 years ago
weird, are u using fastify or express?
2 years ago
hmmm im using express so it might have a difference
2 years 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
2 years ago
couldnt find any other issue related to fastify and 502
2 years ago
yep its alright
but it just works when I add an env variable with the public database url
2 years ago
the private networking isn't available at build unfortunately.
in my case I do the migration on the start script
2 years 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
2 years ago
If you're sure of that then ok
2 years ago
but tbh I would just move the migration script to the start command
2 years ago
yep, are u using prisma?
2 years ago
ah typeorm
2 years ago
yep but my backend contains a healthcheck
if yours dont then it would just fail
2 years ago
but its pretty simple to setup one
https://docs.nestjs.com/recipes/terminus#setting-up-a-healthcheck
2 years ago
this is my script with prisma:
"start": "prisma generate --no-hints && prisma migrate deploy && node dist/src/main",2 years ago
Railway will hold the deployment of your application until its actually reachable by doing an HTTP ping to a /health endpoint
2 years ago
you've to configure it in the service settings
2 years ago
trying to restart? you mean an infinite loop of fail restart?
2 years ago
nope, thats another setting

2 years ago

2 years 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 };
}
}2 years ago
yep it should be alright
2 years 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
2 years ago
makes sense <:kekw:788259314607325204>
ive added the route, but its not working, probably because previous deploy was not with port
2 years ago
wdym by not working? 502 or build not going through?
2 years ago
no port yet? Railway should just do a load balance so both of the deploys will contain the port
2 years ago
yep, i'll see if I can get my fastify app to see what I did but it just worked 💀
2 years ago
yep it just works 💀

2 years ago
I use to validate my env variables and then import it elsewhere
2 years ago
yes
2 years ago
you mean in terms of pricing?
2 years ago
well Railway's memory pricing is not that cheap but if your just using for cache it should be alright
2 years ago
I used to host a bullmq queue with at least 16k per minute inserts and it was pretty cheap IMO
2 years ago
great!
2 years ago
boa noite!