Jump to content

[Solved] Nodejs app port error


cobvan

Recommended Posts

hi,

i'm unable to run nodejs app, i'm getting error about port that is already in used. i tried many ports but same error every time. i also tried process.env.PORT but it is undefined.

Error: listen EADDRINUSE: address already in use 127.0.0.1:3000

 

thanks,

Link to comment
Share on other sites

There you go https://cobvan.helioho.st/

Problems I found:

  1. Your domain was disabled. I assume you did that on purpose because of my warning that you had used 530 GB of memory in the last 24 hours. I re-enabled it.
  2. Node.js was disabled on your domain. Maybe this got disabled when you disabled the domain, but obviously Node isn't going to work while it's disabled so I re-enabled it.
  3. Your app.js file doesn't look anything like the guide. I assume you started with the wiki version and then just started randomly changing things and it evolved into what it was. I backed up your copy with the name app.js.bak and set app.js to exactly what the guide says to use.
  4. Most of your memory usage was coming from npm so I renamed package.json to package.json.bak in case it was interfering, and if nothing else it disables it so npm won't try to read from it or anything. It's not needed for the basic wiki guide anyways.
  5. The index.html file in httpdocs takes precedence over your Node app if it exists. I deleted it.

Now that you have a working copy I recommend making small changes, and testing it frequently. Keep in mind that it gets cached, unless you hit the restart app button, so if you make some changes and they don't show up remember to restart it. A big mistake that most people make is just dropping in a Node app that wasn't designed to run on Passenger and expecting it to just work because "it works on my computer." As long as you make small changes you can see immediately when something goes wrong, revert it, and figure out why it's not working.

Regarding the high load, 497+ GB of memory was from your random npm stuff. The Passenger memory usage was only 17 GB. Honestly, you don't ever have to run npm at all. Just download all the dependencies on your home computer and then upload the node_modules directory. Like I said on Discord, try to keep your memory usage under 200 GB per day. If you're curious how much memory you're currently using, just ask.

Link to comment
Share on other sites

  • Krydos changed the title to [Solved] Nodejs app port error
  • Krydos locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...