Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

OSError: [Errno 98] Address already in use

I understand why this is happening. But I have no idea no to fix it.

I was testing an app on localhost'/0.0.0.0' port:8000 and forgot to ctrl-C out of the app.run() before I closed the workspace and browser windows. Now I cannot run my app because Safari has the hostname, port bound to my previous session. I even cleared history and cookies and restarted Safari and it still gives same message.

PLEASE HELP. surely there is a console command to kill the app running there and free up the port.

2 Answers

Akshay Alok
Akshay Alok
7,857 Points

You can use the method Andrew (Chalkley) has described too. Run:

ps -aux

on the console to see the processes (ps) running at the time and identify the process you want to manipulate (kill in this case). You would want to kill a process which is already listening to the port you want to use and the process while using the workspaces is labeled something like: "treehou+" . You will a process ID (PID) next to the name and the command which initiated the process in the last column or so. Now just run

kill -9 <PID>

on the console and then try again.

Edit: Here is the video for better reference: https://teamtreehouse.com/library/creating-a-simple-server watch @ 5min 09sec