Shards Error while hosting discord bot

Hey @bullfrog098, welcome to the Glitch Forums!

I don’t know much off-hand about Discord.js’s sharding, but the error you’re seeing tells me that you’re probably trying to open more than one listener process. We only allow the port represented by process.env.PORT to be listened to (typically port 3000, but that can change under some circumstances) and if your code tried to listen to that port more than once you’ll see an error like this - basically you’re already listening to port 3000 and you’re telling your code to listen to it again.

My guess is that you’ve got code like const listener = app.listen(process.env.PORT, function() in server.js and the ShardingManager is running that code twice.

What I can’t tell you right now is how to resolve that issue with the ShardingManager. I’d be happy to take a look as soon as I can; would you be willing to share your project name? You can email it to support@glitch.com if you’d prefer to keep it private. Or perhaps someone else here has some direct experience with the ShardingManager and can offer some guidance.

7 Likes