Skip to content
Sign upLog in
← Back to Community
How do I stop my nodejs repl from falling asleep?
Profile icon
Will_builder8

I tried using Uptime robot, but it still falls asleep after a while! How do I fix this?

Voters
Profile icon
DevTeria
Profile icon
SaeedMohd1
Profile icon
McJoe21
Profile icon
Will_builder8
Comments
hotnewtop
Profile icon
vedprad1

It doesn't seem to be down. There is probably a problem in your code, then.
While this may not solve the problem, I do notice that you are missing a lot of semicolons. You should fix that.

Profile icon
Will_builder8

@vedprad1
i dont nee dto put semicolons in nodejs i thought

Profile icon
Zavexeon

@Will_builder8 Semicolons are still necessary in Node. Node is just plain old Javascript with built-in libraries. The syntax is the same.

Profile icon
agarbot9

const uptime = require(”uptime-express”)
uptime.start(3000)

Profile icon
Zavexeon

Keep in mind, if your repl comes across an error it will automatically shut down, and will not automatically wake up. You have to manually restart the repl if that happens.

Profile icon
Vandesm14

Can you send me a screenshot of your Uptime Robot monitor?

Profile icon
Will_builder8
Profile icon
Vandesm14

@Will_builder8 Either place the "keep_alive" code into your main file, or use require('./keep_alive.js') instead of const keep_alive require('./keep_alive.js').
The way you have it now will set the file keep_alive.js to the variable keep_alive instead of running it. Try without the const keep_alive = first and see if that fixes it.

Profile icon
Vandesm14

@Will_builder8 Does that fix your issue?