Resolving The Problem Of Port 5000 Already Being In Use

A Quick Tutorial On macOS Monterey

Tobias Wissmueller

--

Photo by Clément Hélardot on Unsplash

Are you experiencing a problem where you are unable to start a service on your Mac that is using port 5000?

Maybe you are a flask developer and banging your head against the wall why your app won’t start?

This post provides the background of why port 5000 is already being in use and blocking your application. It is walking you through the options and steps on how to resolve it.

It so happened to me recently while switching to a new MacBook and trying to get a flask app running again.

When starting the app I always got the following message:

Ports are not available: listen tcp 0.0.0.0:5000: bind: address already in use

This is the machine I am working on:

  • macOS Monterey Version 12.0.1
  • Macbook Pro (16-inch, 2021)
  • Apple M1 Max

My first action was to check what is using port 5000 by calling lsof -i:5000 in the terminal.

~ % lsof -i:5000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ControlCe 20931 --------- 22u IPv4 0xa77c95dcd16d38f7 0t0 TCP *:commplex-main (LISTEN)

--

--

Tobias Wissmueller

Documenting my Tech-Stack: Jetpack Compose for Android, SwiftUI for iOS and more and more Kotlin Multiplatform for everything.