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 "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 <module>
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 (3224) [earned 5 cycles]
View Answer
Comments
hotnewtop
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 socket.io in Node.js, if you still want to host it on replit.

RYANTADIPARTHI (6041)

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

HarperframeInc (455)

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

jake3jam (0)

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