Skip to content
← Back to Community
Python Socket in Replit
Profile icon
Illusion705

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 "0.0.0.0", but now when I run my client code, it gives the following error:

Traceback (most recent call last):
File "main.py", line 11, in
client.connect(ADDR)
ConnectionRefusedError: [Errno 111] Connection refused

My server: https://replit.com/@Illusion705/Socket-Chat-server?v=1

My client: https://replit.com/@Illusion705/Socket-Chat-client?v=1

How do I fix this?

Answered by InvisibleOne [earned 5 cycles]
View Answer
Voters
Profile icon
sepiainfinite
Profile icon
Illusion705
Comments
hotnewtop
Profile icon
InvisibleOne

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 socket.io in Node.js, if you still want to host it on replit.

Profile icon
jake3jam

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

Profile icon
RYANTADIPARTHI

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

Profile icon
HarperframeInc

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