localhost means the database is being run on the same host as the program accessing it. Its unlikely you’ve installed a mongo database on Glitch, so you’ll need to find the connection string from where you have it hosted.
The following is how to work out the url from MongoDB Atlas, if by chance you have it hosted there.