Member-only story

Resolving The Problem Of Port 5000 Already Being In Use

A Quick Tutorial On macOS Monterey

Tobias Wissmueller
3 min readDec 13, 2021
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)
ControlCe 20931 --------- 23u IPv6 0xa77c95dcd16c66df 0t0 TCP *:commplex-main (LISTEN)

The result: One service with the name “ControlCentre” and a process ID of 20931 is already using port 5000.

Check the resources below to read up on what the Control Centre is actually good for. Here is a quick quote from the manual:

Control Centre on Mac gives you quick access to key macOS settings — such as volume, brightness, Wi-Fi or Focus — and indicates when your Mac is using a camera or microphone. You can customise Control Centre to add other items, such as accessibility shortcuts or Fast User switching.

Well, if you try to kill the process with kill -9 20931, don't even bother. It will restart immediately again.

There are two options:

  1. Use another port for your application.
  2. Dig a little deeper and maybe find a…

--

--

Tobias Wissmueller
Tobias Wissmueller

Written by Tobias Wissmueller

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

Responses (6)

Write a response