Problems with the port

#1

Hello,

I have a problem, I have a nodejs app that in turn has a Dashboard to edit bot configurations through an interface.

This website to emulate uses port 3000 (the default port to be shown as a web) but the problem is as follows:

• If I do not indicate the process.env.port in the index.js, it does not load said Dashboard.

• If the specific in the index.js does not load the Dashboard (Because Port 3000 is being used)

I have made a temporary solution, it consists of:

• Specific in the index.js the port and once you have started changing the port number to 3001, in this way or to Dashboard you can use port 3000.

Of course, this solution is effective, but the problem is that with the glitch restarts the projector generates again the errors that I mentioned previously, it does not load and it remains as “waiking up …”

The name of my project is “yuukibot-dashboard”

#2

Hey @iLxlo_Oficial I can’t find the project you’ve mentioned; can you confirm the project name so we can take a closer look? I’m not quite sure I understand what you’re saying in your description so I’d like to look at your code.

Speaking generically, though, Glitch only opens a single port to the internet - typically 3000, but it can change under certain circumstances. If you don’t override it in your .env file then process.env.PORT will always have the right value. If you’re using that value somewhere and are being told that the port is in use then the most likely scenario is that you’re starting two listeners to that port when you should only be starting one. Looking at your code may allow us to give you specific guidance.

#3

yuukibot-dashboard ( https://yuukibot-dashboard.glitch.me )

#4

Hey @iLxlo_Oficial this took me a little while to suss out, so sorry for the hold up.

I think you’re running into a port collision because when you uncomment the lines at https://glitch.com/edit/#!/yuukibot-dashboard?path=index.js:88:0 because you’ve already started a listener at https://glitch.com/edit/#!/yuukibot-dashboard?path=util/dashboard.js:273:0. You should start an Express app in only one of those two places, not in both.

Hope this helps!

1 Like