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:
- Open System Preferences.
- Go to Sharing.
- 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.
- Open the
docker-compose.yml
file located in your project directory, such asib-gateway-docker/docker-compose.yml
. - Find the line that specifies the ports (around line 41).
ports: - "0.0.0.0:5000:5000"
- Change the port mapping from
5000
to an available port, such as5001
:
ports: - "0.0.0.0:5001:5000"
- Save the changes and restart your Docker containers using the following commands:
docker-compose down docker-compose up -d
- Access the application through the new port by changing the URL from
http://127.0.0.1:5000
tohttp://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.