Introduction:
Once upon a time, in the bustling world of web development, a passionate developer named Suru(Yeah, that’s me) or Chris to some people. So, I was on this big mission to create a revolutionary web application using Django (A python framework).
After winning the battle of self doubt and procrastination, I was armed to teeth with the knowledge of Python and a vision, I embarked on the coding adventure, eager to conquer the digital realm.
However, as I fired up the Django development server, an unexpected hurdle appeared: “Error: You don’t have permission to access that port.”
Chapter 1: The Port Paradox
I was perplexed but undeterred, I knew that the error meant another process had taken over port 8000 — the default port Django uses. It was like an apartment with no entrance door! Frowning at the screen, and I pondered on my next line of action which is the first step to victory.
After giving it much thought, I realized there are two ways to fix this!
Chapter 2: The Crafty swerve (Changing to Another Port)
I decided to act on the first steps which is to outwit the predicament by changing to another port — 8001, that sounds like a great choice right? Armed with determination, and without much ado I swiftly ran the following command:
# Windows
python manage.py runserver 8001
Lo and behold, the Django development server came alive, and the web application was now accessible on port 8001. Success!
Note: You should use a dedicated virtual environment for each new Python project.
Chapter 3: The Mighty Conqueror(Terminating the Current Process)
The second method is to find and terminate the process using the port. I will not explain why you should or not terminate a process, but, if there’s need to terminate the process, you can do so. Open your terminal and run the below code
For Windows, open terminal with Win + R, type cmd to open terminal
# Windows
netstat -ano | findstr :8000
taskkill /PID 12345
Note: Replace 12345 with the port ID using the port you wish to replace.
For Linux/macOS
# Identify the process using port 8000
lsof -i :8000
# Kill the process using port 8000 (replace <PID> with the actual process ID)
kill <PID>
Conclusion: A Big Victory
The story “A Django Tale: Outsmarting the Port Predicament”, teaches us that as we journeyed through software development, there are bound to be challenges that’ll want to make us quit, but, we should remember, that they just stepping stones to greatness.
If you have insights, better ways, or suggestions, I wholeheartedly encourage you to share them. Let’s make this space a collaborative one where ideas flourish, and knowledge is freely exchanged. Together, we’ll not only master the art of software development but also uncover the limitless possibilities technology offers.
Top comments (0)