1 year ago
#172317
CR47
I am getting listen EADDRINUSE: address already in use with an ExpressJS application in Lando via Docker for Windows in WSL Ubuntu 20.04
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.
node.js
docker
express
windows-subsystem-for-linux
lando
0 Answers
Your Answer