Resolving Port Conflict with Apple's AirPlay Receiver on Port 5000

Problem:

If you encounter the error message Port not available: exposing port TCP 0.0.0.0:5000 -> 0.0.0.0: listen TCP 0.0.0.0:5000: bind: address already in use, it indicates that port 5000 is already in use by another process. Running the lsof command to identify the process shows that a process named ControlCe with PID 395 is currently using the port.

$ lsof -i :5000
COMMAND     PID    USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
ControlCe   395   user1   22u  IPv4 0x361e8dfd90bd1ee9      0t0  TCP *:commplex-main (LISTEN)
ControlCe   395   user1   23u  IPv6 0x361e8dfd8b640a61      0t0  TCP *:commplex-main (LISTEN)

Solution 1: Disable AirPlay Receiver

The issue appears to stem from Apple's AirPlay Receiver occupying port 5000. Apple uses this port for the AirPlay Receiver service. To resolve this conflict, you can disable the AirPlay Receiver:

  1. Open System Preferences.
  2. Go to Sharing.
  3. Uncheck AirPlay Receiver.

By disabling the AirPlay Receiver, port 5000 will become available for your application.

 

Solution 2: Change the Port in Docker Configuration

If you prefer not to disable AirPlay Receiver or if you want to use a different port, you can modify the port number in your Docker configuration.

  1. Open the docker-compose.yml file located in your project directory, such as ib-gateway-docker/docker-compose.yml.
  2. Find the line that specifies the ports (around line 41).
  ports:
  - "0.0.0.0:5000:5000"

  1. Change the port mapping from 5000 to an available port, such as 5001:

  ports:
  - "0.0.0.0:5001:5000"

  1. Save the changes and restart your Docker containers using the following commands:
docker-compose down
docker-compose up -d

  1. Access the application through the new port by changing the URL from http://127.0.0.1:5000 to http://127.0.0.1:5001.

By following these steps, you can resolve the port conflict and successfully run your application on an available port.

Further details and procedures, I highly recommend referring to the comprehensive Udemy course available here: Link to Udemy Course.

Subscribe to TBOT on TradingBoat

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe