Glitch Console Error


#1

I get this error when using node index.js

events.js:183
throw er; // Unhandled ‘error’ event
^
Error: listen EADDRINUSE :::3000
at Server.setupListenHandle [as _listen2] (net.js:1360:14)
at listenInCluster (net.js:1401:12)
at Server.listen (net.js:1485:7)
at Function.listen (/rbd/pnpm-volume/54db381e-5536-40ee-8bb5-2d1aa23e5bde/node_modules/.registry.npmjs.org/express/4.16.4/node_modules/express/lib/applica
tion.js:618:24)
at Object. (/app/index.js:9:5)
at Module._compile (module.js:653:30)
at Object.Module._extensions…js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)


#2

Hi @HeadTriXz, welcome to the Glitch Forums!

This error typically indicates that you’re trying to listen to the single port that Glitch opens in more than one place is your code, and when it reaches the point in index.js where you start to listen the port’s already connected.

If you can provide your project name someone can probably give more specific advice.


#3

The name is wedesign-bot


#4

Ok, I’m not seeing any errors in that project. Can you tell us precisely what steps you’re taking when you encounter the error?


#5

I just type node index.js in the console.


#6

Ah, yes, that will not work.

Glitch is already running your project using the node index.js command in your package.json file. When you run node index.js in the console it tries to run it again, but since it’s already running the requested port is already open and thus the error.

Can I ask what it is that you’re trying to accomplish by running that in the console? Perhaps something in the rest of your project’s configuration (maybe in a watch.json file) is preventing Glitch from picking up changes that you want to see?


#7

I want to use the console of the index file so I can send messages through the console.


#8

You won’t be able to use those two methods simultaneously; either your project as executed by Glitch based on the package.json file can run or you can run your project from the console using node index.js. If this is just something you want to do during testing you could change your package.json file so that it doesn’t run index.js when it starts up and then start your app using the console, but you’d have to keep in mind that when Glitch shuts down your project it won’t start it up again automatically if package.json doesn’t tell it what to do.

If you’re looking to do this more long term then you’ll need another mechanism. You could make the app part of your project into an API that you can call from the console using curl, for instance, or build a command that does what you want from the Discord side an just use the bot to execute that command.

Hopefully I haven’t completely misinterpreted what you’re hoping to do, but if I’m off-base then please give us some more detail.