Trying to deploy my backend but it always says "Application failed to respond"
Here's the repo: https://github.com/Kweebac/messagingApp/
I started a new project, created a MongoDB database and added the shared variable
MONGO_PRIVATE_URL
, added all my other ENV variables, changed the root directory to /server
and generated a domain. The deployment worked, but when I go to the domain it says "Application failed to respond".
In the logs it says this, and keeps restarting over and over.45 Replies
Project ID:
N/A
make sure your app is listening on the PORT provided by Railway
I recommend you check this out: https://docs.railway.app/guides/fixing-common-errors
Thank you, I didn't know about this
And wow that was a quick response lol
no problem 🙂
Fixed, thank you :)
Awesome, I'm happy to help! :D
Just noticed it's still giving me this error and restarting over and over, yet on the domain it seems fine?
Can I just ignore this lol
Mind sending me a screenshot of your memory metrics in your service?
How do I do this?
Not sure what memory metrics are haha
in your service you'll see a
Metrics
tabyou can click on that to see your application's metrics, it shows info about your app's cpu, memory and network usage
dang your app uses next to no memory, what the flip
Is that a good or a bad thing...
typically a good thing but I feel this may not be intended here
I'm wondering if your app may be trying to allocate more than 500mb of memory quickly after starting up, and if that fails your app exits making it show no memory usage even though it wants to use a ton of memory
So I need to increase the 500mb cap or something?
If I'm right then yes that would be the solution, and you can do that by upgrading to hobby plan ( which increases the cap from 500mb to 8gb )
Although, I'm not 100% certain that this is in fact the issue
I have the frontend hosted on Vercel and it seems to be communicating with the backend correctly though lol
This is strange
oh, maybe it's just an operation in your app that's failing to allocate the required memory instead of your entire app then 🤔
oh well, if it works it works 😆
The backend just crashed so I take that back 😅
oh 💀
then this is still my best guess about what's happening
Do most MERN apps need more than 500mb of memory allocated like this or have I just wrote bad code or something lol
wait one last idea, could you try setting a
NODE_OPTIONS
service variable to --max-old-space-size=8192
Haha well the error changed
Now it just says "Killed"
And restarts over and over
After doing this
it largely depends on your app itself, like how big of a userbase it has and what specifically goes on inside of it, I use a similar stack and my apps use around 100mb to 300mb depending on the scale
okay definitally a step in the wrong direction then 🤣
I'm gonna go ahead and lock in on this then
Feel free to wait for a second opinion though
Maybe someone else has an idea
I also get a CORS error now interestingly
I'll try upgrading to Hobby plan
Sounds good, hopefully that does solve your issue
Nice I get a $5 discount anyway so it's basically free
Yeah... I've been trying to host my website for 2 days now and I can confidently say it's the worst part of webdev ðŸ˜
lmao, fr
Railway's mission is to make it the easiest part of web dev 🚀
Damn it
It seemed like it was fixed then it just sent the error again haha
Darn, that's unfortunate
Bit of a bigger error this time, looks mostly similar though
It restarts every minute or so now instead of immediately like last time
so it runs for about a minute before crashing?
Yeah lol
The Railway deployment doesn't crash
It just restarts it every minute
Solution
I wouldn't recommend using
nodemon
in productionnodemon is strictly meant for development
Nice to know, I'll try fixing that now lol
Honestly the first 2 days I tried doing this I didn't even know the frontend and backend were meant to be deployed separately LOL
So just
node
instead?exactly
Seems to be working now, API calls do feel noticeably slower now that I'm not using
localhost
, is this normal?yea, when you're testing locally then your apps are in the same machine and so requests are practically instant as opposed to running in development where the server is usually far away from the client computer
your deployment is running in US-west, so if you're far away from western US then API calls will be significantly slower
Ah okay, thank you for all your help :)
This whole experience was just depressing lol, time to go do fun things with my life again
lmao, enjoy!
of course, any time :SmileFluent: