Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7574989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:34:26+00:00 2026-05-30T16:34:26+00:00

I have this code (hello.py): import os,sys import tornado.ioloop import tornado.web import tornado.httpserver #http

  • 0

I have this code (hello.py):

import os,sys
import tornado.ioloop
import tornado.web
import tornado.httpserver

#http server class
class http_server(tornado.web.RequestHandler):
  def get(self):
    self.write("Hello, getter!")
  def post(self):
    self.write("Hello, poster!")

#create http server
Handlers     = [(r"/",http_server)]
App_Settings = {"debug":True}
HTTP_Server  = tornado.web.Application(Handlers,**App_Settings)

#run http server
HTTP_Server.listen(9999)
tornado.ioloop.IOLoop.instance().start()

It runs fine for the first time with this command from terminal:

python hello.py

After this, the terminal keep waiting for output by Tornado. When i open http://localhost:9999, it returns “Hello,getter!” as wanted. But for the second time, Python shows an error:

Traceback (most recent call last):
  File "hello.py", line 19, in <module>
    HTTP_Server.listen(9999)
  File "/usr/local/.../tornado/web.py", line 1227, in listen
    server.listen(port, address)
  File "/usr/local/.../tornado/netutil.py", line 100, in listen
    sockets = bind_sockets(port, address=address)
  File "/usr/local/.../tornado/netutil.py", line 265, in bind_sockets
    sock.bind(sockaddr)
  File "<string>", line 1, in bind
socket.error: [Errno 98] Address already in use

I press Ctrl-Z to send ‘hello.py’ to background, but this doesn’t release the port. If i close the terminal, the port is released. However the path to the python source file is deeply nested in directories, so i don’t want to close the terminal and restart it after every single change in the code. Some suggested to me that i should use debug=True in application setting but this doesn’t seem to be related to the matter that Tornado keeps holding the port.

I also tried “pidof python”, then kill all python processes but the port is still held by the stubborn Tornado. Is there any way to release all the ports held by Tornado with some Python statement? or manually?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T16:34:27+00:00Added an answer on May 30, 2026 at 4:34 pm

    Not really an answer to your question if you can release the Tornado ports using a Python statement, but since it seems to have solved your problem, I thought I’d write up a short answer anyway;

    Ctrl-Z will only put your program to sleep but not release any ports.

    If you on the other hand use Ctrl-C, the program will be stopped entirely. That will allow you to simply use shell history to start it again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have this code: <?php class hello { var $greeting = hello;
I have this trivial code: from sys import argv script, input_file = argv def
i have to create connecting server<=>client. I use this code: Server: import socket HOST
Suppose I have this code: String encoding = UTF-16; String text = [Hello StackOverflow];
Problem Hello all! I have this code which takes my jpg image loops through
Hello i have this form filling javascript: function onLine(code,nn) { document.writeform.bericht.value+=code; document.writeform.bericht.focus(); document.writeform.nickname.value+=nn; write1();
I have a C++ DLL with code like this: LogMessage( Hello world ); try
I am new to programming.I have seen this code.returning a derived class object to
i have this opensource code which is used to echo back response to web-socket
I have this code in jQuery, that I want to reimplement with the prototype

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.