Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

(duplicate) [WinError 10061] No connection could be made because the target machine actively refused it

I’m asking this type of question although people already asked for its answers but I couldn’t fix my problem still.

I’ve made a python code (from a learning course about networking) that goes like this :

import socket

my_socket = socket.socket()
my_socket.connect(('127.0.0.1',8820))
my_socket.send('omer'.encode())
data = my_socket.recv(1024).decode()
print('The server sent:' + data)
my_socket.close()

the error I’m getting is this Traceback (most recent call last): File "e:/VISUAL STUDIO CODE/the good stuff/networking learning/ex2_1.py", line 4, in <module> my_socket.connect(('127.0.0.1',8820)) ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

any explanation for why it doesn’t run this simple code would be great, thanks

*edit: I used both visual studio code and pycharm to run this and got the same result

>Solution :

The meaning of this error is simple: it means that there is no server process on IP address 127.0.0.1 (your own computer) which is listening to port 8820.

If you want to connect to a port you must choose an IP address and port where there is a server running.

You were probably supposed to run a server program on your computer and then run this client program at the same time.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading