Trying to deploy my backend but it always says "Application failed to respond"
kweebac
TRIALOP

2 years ago

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.

67 Replies

dev
MODERATOR

2 years ago

make sure your app is listening on the PORT provided by Railway
I recommend you check this out:


kweebac
TRIALOP

2 years ago

Thank you, I didn't know about this


kweebac
TRIALOP

2 years ago

And wow that was a quick response lol


dev
MODERATOR

2 years ago

no problem 🙂


kweebac
TRIALOP

2 years ago

Fixed, thank you :)


dev
MODERATOR

2 years ago

Awesome, I'm happy to help! :D


kweebac
TRIALOP

2 years ago

Just noticed it's still giving me this error and restarting over and over, yet on the domain it seems fine?

1223597128077545500


kweebac
TRIALOP

2 years ago

Can I just ignore this lol


dev
MODERATOR

2 years ago

Mind sending me a screenshot of your memory metrics in your service?


kweebac
TRIALOP

2 years ago

How do I do this?


kweebac
TRIALOP

2 years ago

Not sure what memory metrics are haha


dev
MODERATOR

2 years ago

in your service you'll see a Metrics tab

1223597913679200300


dev
MODERATOR

2 years ago

you can click on that to see your application's metrics, it shows info about your app's cpu, memory and network usage


kweebac
TRIALOP

2 years ago

1223598117190897700


dev
MODERATOR

2 years ago

dang your app uses next to no memory, what the flip


kweebac
TRIALOP

2 years ago

Is that a good or a bad thing…


dev
MODERATOR

2 years ago

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


kweebac
TRIALOP

2 years ago

So I need to increase the 500mb cap or something?


dev
MODERATOR

2 years ago

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 )


dev
MODERATOR

2 years ago

Although, I'm not 100% certain that this is in fact the issue


kweebac
TRIALOP

2 years ago

I have the frontend hosted on Vercel and it seems to be communicating with the backend correctly though lol


kweebac
TRIALOP

2 years ago

This is strange


dev
MODERATOR

2 years ago

oh, maybe it's just an operation in your app that's failing to allocate the required memory instead of your entire app then 🤔


dev
MODERATOR

2 years ago

oh well, if it works it works 😆


kweebac
TRIALOP

2 years ago

The backend just crashed so I take that back 😅


dev
MODERATOR

2 years ago

oh 💀


dev
MODERATOR

2 years ago

then this is still my best guess about what's happening


kweebac
TRIALOP

2 years ago

Do most MERN apps need more than 500mb of memory allocated like this or have I just wrote bad code or something lol


dev
MODERATOR

2 years ago

wait one last idea, could you try setting a NODE_OPTIONS service variable to --max-old-space-size=8192


kweebac
TRIALOP

2 years ago

Haha well the error changed


kweebac
TRIALOP

2 years ago

Now it just says "Killed"


kweebac
TRIALOP

2 years ago

And restarts over and over


kweebac
TRIALOP

2 years ago

After doing this


dev
MODERATOR

2 years ago

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


dev
MODERATOR

2 years ago

okay definitally a step in the wrong direction then 🤣


dev
MODERATOR

2 years ago

I'm gonna go ahead and lock in on this then


dev
MODERATOR

2 years ago

Feel free to wait for a second opinion though


dev
MODERATOR

2 years ago

Maybe someone else has an idea


kweebac
TRIALOP

2 years ago

I also get a CORS error now interestingly


kweebac
TRIALOP

2 years ago

I'll try upgrading to Hobby plan


dev
MODERATOR

2 years ago

Sounds good, hopefully that does solve your issue


kweebac
TRIALOP

2 years ago

Nice I get a $5 discount anyway so it's basically free


kweebac
TRIALOP

2 years ago

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 😭


dev
MODERATOR

2 years ago

lmao, fr


dev
MODERATOR

2 years ago

Railway's mission is to make it the easiest part of web dev 🚀


kweebac
TRIALOP

2 years ago

Damn it


kweebac
TRIALOP

2 years ago

It seemed like it was fixed then it just sent the error again haha


dev
MODERATOR

2 years ago

Darn, that's unfortunate


kweebac
TRIALOP

2 years ago

Bit of a bigger error this time, looks mostly similar though

1223602399080484900


kweebac
TRIALOP

2 years ago

It restarts every minute or so now instead of immediately like last time


dev
MODERATOR

2 years ago

so it runs for about a minute before crashing?


kweebac
TRIALOP

2 years ago

Yeah lol


kweebac
TRIALOP

2 years ago

The Railway deployment doesn't crash


kweebac
TRIALOP

2 years ago

It just restarts it every minute


kweebac
TRIALOP

2 years ago


dev
MODERATOR

2 years ago

I wouldn't recommend using nodemon in production


dev
MODERATOR

2 years ago

nodemon is strictly meant for development


kweebac
TRIALOP

2 years ago

Nice to know, I'll try fixing that now lol


kweebac
TRIALOP

2 years ago

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


kweebac
TRIALOP

2 years ago

So just node instead?


dev
MODERATOR

2 years ago

exactly


kweebac
TRIALOP

2 years ago

Seems to be working now, API calls do feel noticeably slower now that I'm not using [localhost](localhost), is this normal?


dev
MODERATOR

2 years ago

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 in a server 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


kweebac
TRIALOP

2 years ago

Ah okay, thank you for all your help :)


kweebac
TRIALOP

2 years ago

This whole experience was just depressing lol, time to go do fun things with my life again


dev
MODERATOR

2 years ago

lmao, enjoy!


dev
MODERATOR

2 years ago

of course, any time <:SmileFluent:865334941150871592>


Loading...