title: Tor failing to run with Failed to bind one of the listener ports
body: <p>When I run the [example][1] from the stem documentation i get the error:</p>
  
  <pre><code>OSError: Process terminated: Failed to bind one of the listener ports.
  </code></pre>
  
  <p>The exact code that I am running is below:</p>
  
  <pre><code>import socks
  import socket
  import stem.process
  import urllib
  
  from stem.util import term
  
  SOCKS_PORT = 7000
  
  # Set socks proxy and wrap the urllib module
  
  socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, '127.0.0.1', SOCKS_PORT)
  socket.socket = socks.socksocket
  
  # Perform DNS resolution through the socket
  
  def getaddrinfo(*args):
    return [(socket.AF_INET, socket.SOCK_STREAM, 6, '', (args[0], args[1]))]
  
  socket.getaddrinfo = getaddrinfo
  
  def query(url):
      return urllib.urlopen(url).read()
  
  def print_bootstrap_lines(line):
    if "Bootstrapped " in line:
      print(term.format(line, term.Color.BLUE))
  
  print(term.format("Starting Tor:\n", term.Attr.BOLD))
  
  tor_process = stem.process.launch_tor_with_config(
    config = {
      'SocksPort': str(SOCKS_PORT),
      'ExitNodes': '{ru}',
    },
    init_msg_handler = print_bootstrap_lines,
  )
  
  print(term.format("\nChecking our endpoint:\n", term.Attr.BOLD))
  print(term.format(query("https://www.atagar.com/echo.php"), term.Color.BLUE))
  
  print(query("https://stackoverflow.com/questions/30286293/make-requests-using-python-over-tor"))
  
  tor_process.kill()  
  </code></pre>
  
  <p>I have seen answers saying that there is another process running on port 9050, but runniing the command <code>sudo netstat -anl | grep 9050</code> in the terminal gives me no result.</p>
  
  <p>Please feel free to suggest anything that might help.</p>
  
  <p>In addition, the first example on the "to russia with love" works flawlessly.</p>
  
  <p>Thanks for any help that you can give.</p>