Hi,
I’m trying to use Glitch to host a Discord bot and have managed to make my code work except… the code only runs if I’m using the editor, or looking at the console. If I close either, the script instantly stops working (and my bot goes offline). Visiting my project’s homepage does not seem to start the script either.
I don’t know if there’s something wrong in my code that causes it to only run when the console is open, or if I’m mistaken on the use of Glitch lol.
On another note, I’ve set up UptimeRobot as well and it seems unable to find my project (shows no uptime nor downtime).
My project’s name is sunshine-kachbot. Any help appreciated, thank you.
The issue here, I think, is that you’ve set the PORT environment variable in your project’s .env file to an invalid value. Generally speaking it’s best to let Glitch control the PORT - we’ll set it to the appropriate value (typically 3000, but that can change under certain circumstances).
If you remove that line from your .env file I think things will start working appropriately.
Thank you! I looked up things and some boards I found had said to write something like this but I guess that was wrong aha. It seems like the app is properly working now even when I have the editor closes, thanks so much!
That all looks right! I checked on your project and it seems like it just hadn’t restarted after you removed the PORT value, so hadn’t picked up the change. I ran the refresh command in your project’s console and everything looks good now!