title: How to solve twisted.internet.error.CannotListenError: Couldn't listen on any:8081: [Errno 98] Address already in use
body: <p>I have a twisted python server which runs on port 8080, and i have written different API's which runs on this server. so i want all these API's to run on a single port no. but when i try to use same port all API's for ex : 8081 and run at the same time using python interpreter. at that time i am getting this error : twisted.internet.error.CannotListenError: Couldn't listen on any:8081: [Errno 98] Address already in use.
  As i am new to twisted so don't know much of the things and there is no proper documentation on twisted . please someone guide me to solve this error : </p>
  
  <p>Here is the Code snippets :</p>
  
  <pre><code>from twisted.internet import epollreactor
  
  epollreactor.install()
  
  from zope.interface import implements
  from twisted.internet import reactor,interfaces
  from functools import partial
  from pymongo import Connection
  import json
  from bson.objectid import ObjectId
  import server_1
  import replacePlus_Space
  
  global data, data_new, datadB, coll_auth, coll_person
  
  
  class Login_user(server_1.HTTPEchoFactory):
  
      def __init__(self):
          server_1.HTTPEchoFactory.__init__(self,"testsite")
          server_1.HTTPEchoFactory.initResources(self)
          self.initResources()
  
      def initResources(self):
          print "in Login"
          self.responses["/login_user"] = partial(self.user_login)
  
  
      # To connect to DB and Check error cases and insert into mongoDB..!!!
      def user_login(self, client):
          # some functinality..!!!!
  
  d = Login_user()
  
  reactor.listenTCP(8081,d)
  
  reactor.run()         
  </code></pre>
  
  <p>Second code snippet is :</p>
  
  <pre><code>from twisted.internet import epollreactor
  
  epollreactor.install()
  
  from zope.interface import implements
  from twisted.internet import reactor,interfaces
  from functools import partial
  from pymongo import Connection
  import json
  from bson.objectid import ObjectId
  import server_1
  import replacePlus_Space
  
  class AddFriendDB(server_1.HTTPEchoFactory):
  
      def __init__(self):
          server_1.HTTPEchoFactory.__init__(self,"testsite")
          server_1.HTTPEchoFactory.initResources(self)
          self.initResources()
  
      def initResources(self):
          print "in add friend"
          self.responses["/addFriend_DB"] = partial(self.addFriendDB)
  
  
      # To connect to DB and Check error cases and insert into mongoDB..!!!
      def addFriendDB(self, client):
          #some functionality here..!!!
  
  d = AddFriendDB()
  
  reactor.listenTCP(8081,d)
  
  reactor.run()
  </code></pre>