Menu

Port already in use? Find what's holding it and fix it in a minute
📰

Port already in use? Find what's holding it and fix it in a minute

DEV Community: docker·VeloxaHost·3 days ago
#6qtoWoxq
#devtodocker#devto#dev#port#exit
Reading 0:00
15s threshold

You start your app and it dies straight away:

Error: listen EADDRINUSE: address already in use :::3000 bind() to 0.0.0.0:80 failed (98: Address already in use) Bind for 0.0.0.0:8080 failed: port is already allocated

Enter fullscreen mode

Exit fullscreen mode

Three tools, three wordings, one meaning: something else is already listening on that port. Here's how to find out what in about a minute, and how to fix it without breaking anything else.

Step 1: find who owns the port

Ask the kernel. On any modern Linux server:

sudo ss -ltnp 'sport = :3000'

Enter fullscreen mode

Exit fullscreen mode

You'll get a line like:

LISTEN 0 511 *:3000 *:* users:(("node",pid=48213,fd=21))

Enter fullscreen mode

Exit fullscreen mode

That's the process name and its PID. Two alternatives if you prefer them:

sudo lsof -i :3000 sudo fuser 3000/tcp

Enter fullscreen mode

Exit fullscreen mode

Use sudo .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.