mac error that port is already in use
Open the terminal on your Mac.
Use the following command to identify the process ID (PID) that is using the port:
lsof -i :<port_number>
Replace <port_number>
with the actual port number that is in use.
Note the PID from the output.
Terminate the process using the identified PID with the following command:
kill -9 <PID>
Replace <PID>
with the actual process ID obtained in step 3.
- Retry running your Django development server. If the issue persists, choose an alternative port for your Django application:
python manage.py runserver <new_port_number>
Replace <new_port_number>
with the desired port number.
- If you need to find an available port dynamically, use the following command:
python -c "import socket; s=socket.socket(); s.bind(('', 0)); print(s.getsockname()[1]); s.close()"
This will print an available port number. Use it when starting your Django development server.