Ask coding questions

← Back to all posts
Python Socket in Replit
Illusion705 (0)

I tried making a socket program, but I can't seem to get my client to connect to the server. I did some research and found another post that suggested changing the host to "", but now when I run my client code, it gives the following error:

Traceback (most recent call last):
File "", line 11, in <module>
ConnectionRefusedError: [Errno 111] Connection refused

My server:

My client:

How do I fix this?

Answered by InvisibleOne (3224) [earned 5 cycles]
View Answer
InvisibleOne (3224)

As far as I know, sockets do not work in python on replit, due to the fact that it thinks it supposed to create an HTTP server or something like that. You can however use in Node.js, if you still want to host it on replit.


try other editors. Replit doesn't support sockets. But it is available in python

HarperframeInc (455)

Sockets don't work on
You may want to try websockets.

jake3jam (0)

Put the Host on then put the port to like 80 or smtn where replit has it port forwarded automatically