Skip to content
Permalink
Browse files
added kill command instructions
  • Loading branch information
aa7401 committed Jun 30, 2017
1 parent 7316e4e commit 3bdea7829a18a148c070db16d8ece1206b1c233c
Showing 1 changed file with 16 additions and 0 deletions.
@@ -36,6 +36,22 @@ If you get a response of `command not found` or equivalent you will need to inst
sudo apt-get update || sudo apt-get install curl
```

### Port in Use

Sometimes when a nodejs script crashes it keeps the port open which means you will get an error if you try to run your API.
```
Error: listen EADDRINUSE :::8080
```
To fix this you will need to find the PID (process ID) of the script currently using the port and kill it before running your API again.

To see what process is running on a given port (Ubuntu) we can use the [lsof](https://linux.die.net/man/8/lsof) (list open files). The `-i` lists all files of whose internet address matches the address specified (in our case we are looking for any files using the port 8080). Once we have the PID we can pass it to the [kill](http://manpages.ubuntu.com/manpages/xenial/man1/kill.1.html) tool.
```
$ lsof -i :8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 30135 johndoe 12u IPv6 33466259 0t0 TCP *:8080 (LISTEN)
$ kill 30135
```

#### 1.4 Test Your Knowledge

We will practice using cURL using the Web API provided by [GitHub](https://github.com). Your first task is to make sure you have a valid login.

0 comments on commit 3bdea78

Please sign in to comment.