[Twisted-Python] 111: Connection refused

Andrew Bennetts andrew-twisted at puzzling.org
Tue Aug 3 14:48:10 MDT 2004

On Tue, Aug 03, 2004 at 01:16:21PM -0700, Damon Fasching wrote:
> Hi Itamar,
> --- Itamar Shtull-Trauring <itamar at itamarst.org>
> wrote:
> > Telnet to the port where PB is running I mean. e.g.
> > telnet host 9767.
> I can't telnet into the PB port on either machine; the
> machine where PB does accept connections or the one
> where it doesn't.  Wouldn't I need telnetd running to
> do this even if I specify the port?

No, telnet just opens a socket.  You can telnet to any port, and it will
establish a connection if the port is open.  You can even send messages to
text-based protocols, such as HTTP, for instance (I've marked the lines I
typed, the rest is the reply from the server):

    $ telnet www.twistedmatrix.com 80
    Connected to twistedmatrix.com.
    Escape character is '^]'.
 -> HEAD / HTTP/1.0
    HTTP/1.0 200 OK
    Last-Modified: Tue, 03 Aug 2004 09:13:39 GMT
    Content-Length: 6507
    Date: Tue, 03 Aug 2004 20:31:12 GMT
    Accept-Ranges: bytes
    Content-Type: text/html
    Server: TwistedWeb/SVN-trunk
    X-Cache: MISS from home.puzzling.org
    X-Cache-Lookup: MISS from home.puzzling.org:3128
    Connection: close
    Connection closed by foreign host.

But if you telnet to a port that isn't open, you'd get:

    $ telnet localhost 1234
    telnet: Unable to connect to remote host: Connection refused

Judging from the errors you're seeing, I'd expect that telnet to your PB
port on one machine would give the "Connected to foo." message, and the
other would give "Unable to connect to remote host: Connection refused".
Also, try doing these telnets from a different machine and also locally from
the machines running the PB server, you should get the same results, but if
you don't, that might hint at where the problem is.
> Can anyone tell me what I need to have
> enabled/set/configured in order for my Redhat box to
> accept connections on a PB server?

Well, it depends on what the problem is, and we still don't know that.  It
also depends on what your PB server actually is; there's not really any such
thing as a plain "PB server"; that doesn't really tell us anything about
what it is or how it should run.  What application is this PB server?  Is it
run by twistd (and if so, from a tap or a tac)?  Or is it a script that
calls reactor.run() directly?  Etc.

Have you looked in the log files for the service on both machines?  Perhaps
the service is simply failing to start on one, in which case the reason
should be logged there.

You could also try "netstat -ntlp", and see if there is a process listening
on that port, and if so, is it listening on the right interface (probably, and is it the right process.


More information about the Twisted-Python mailing list