user551717
user551717

Reputation: 8661

No connection could be made because the target machine actively refused it

I've tried to connect to my local machine every time I try and run my program. I am a nub, so it's probably a simple mistake somewhere.

def connect(self):
    self.conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    self.conn.connect((self.host,self.port))

That is the code causing the error. The host and port are defined. Why is it giving me this error report?

[Errno 10061] No connection could be made because the target machine actively refused it

Upvotes: 1

Views: 46198

Answers (1)

dutt
dutt

Reputation: 8209

It's because you haven't opened the port you are trying to connect to, nothing is listening there. If you're trying to connect to a web or ftp server, start it first. If you're trying to connect to another port, you need to write a server application too.

Upvotes: 4

Related Questions