Problems connecting to python Socket on a vps (for a chat program)
BMPCreated with Sketch.BMPZIPCreated with Sketch.ZIPXLSCreated with Sketch.XLSTXTCreated with Sketch.TXTPPTCreated with Sketch.PPTPNGCreated with Sketch.PNGPDFCreated with Sketch.PDFJPGCreated with Sketch.JPGGIFCreated with Sketch.GIFDOCCreated with Sketch.DOC Error Created with Sketch.
Question

Problems connecting to python Socket on a vps (for a chat program)

by
MatteoD
Created on 2018-11-06 21:54:03 (edited on 2024-09-04 14:23:56) in Virtual Private Servers

Hello,
I've a **Debian vps** and I'm trying to make a **chat program**. I've the following code running on the server (vps):

import socket
host, port = "51.77.66.55",9999
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((host, port))
s.listen(5)
client,addr = s.accept()
print("Connection received from :",addr)
while True:
msg = client.recv(1024)
print(str(msg,"utf-8"))
and the following running on my machine:

import socket
host, port = "51.77.66.55",9999
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
while True:
msg = input("--> ")
s.send(bytes(msg,"utf-8"))
This code is just a simple test but I can't seem to make it work.
I get the error : **ConnectionRefusedError: [Errno 111] Connection refused**
I'm quite certain this is not a problem with my code because it works fine with 127.0.0.1 on my machine.
The **iptables** of my vps is **open for all the ports**.

Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

**What am I missing here ??**
**Is there another kind of firewall I'm not aware of? Is OVH blocking certain ports?**

thanks a lot

ps : 51.77.66.55 is not the actual ip of my vps but I checked, it not an ip problem either. I also tried with other ports like 80 and got the same results.


Replies are currently disabled for this question.