0

I'm trying to start building an Express/Node/React application on Windows 10 using WSL2, Docker Desktop, and Lando (installed via WSL2) but I'm having issues getting the basic Express portion to run.

Based on Google searches it seems to be most likely Windows related. I don't have much experience developing on Windows and usually use a Linux distro or macOS.

  • OS: Windows 10
  • wsl: Ubuntu 20.04
  • Lando: 3.6.0
  • Docker Desktop: 4.5.0
  • Node: v16.14.0
  • npm: 8.5.0

Here is my /app/server/index.js:

const express = require('express');
const app = express();

app.listen('/', (req, res) => {
    res.send({ foo: 'bar' });
});

app.listen(5000);

Here is my .lando.yml:

name: test
recipe: mean
config:
  node: 16
  build:
    - npm install -g npm
  # command: npm start
  database: mongo:5.0
  globals: []
    # gulp-cli: latest
  port: 80
  ssl: false
proxy:
  appserver:
    - server.test.lndo.site:5000

When running: lando node index.js

I get this error: listen EADDRINUSE: address already in use

node:events:498
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE: address already in use /
    at Server.setupListenHandle [as _listen2] (node:net:1313:21)
    at listenInCluster (node:net:1378:12)
    at Server.listen (node:net:1476:5)
    at Function.listen (/app/server/node_modules/express/lib/application.js:618:24)
    at Object.<anonymous> (/app/server/index.js:4:5)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
Emitted 'error' event on Server instance at:
    at emitErrorNT (node:net:1357:8)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'EADDRINUSE',
  errno: -98,
  syscall: 'listen',
  address: '/',
  port: -1
}

Switching the path in app.listen() just results in the same error.

CR47
  • 843
  • 4
  • 12
  • 33
  • Have you tried killing the port? I have had this same issue with other modules (never used lando) after killing the port via npx kill-port from an administrator console I was able to get it to work. I found windows spins up a bunch of stuff on launch... could be a similar issue here – jsonderulo Feb 13 '22 at 05:31
  • @Shaynel it complains about the path rather than the port. I did check to see if there were conflicting ports in the Windows host machine as well and didn’t see anything on 80 or 5000. – CR47 Feb 13 '22 at 05:43

0 Answers0