We are using django to call APIs (ubuntu server) that are on 172.20.44.148.
Our code is the following:
import socket
socket.create_connection(('172.20.44.148', 8080), timeout=2)
However, the connection refused.
This is the error we got from apache:
[root#xxx ~]# python /home/something.py
Traceback (most recent call last):
File "/home/something.py", line 3, in <module>
socket.create_connection(('172.20.44.148', 8080), timeout=2)
File "/usr/local/lib/python2.7/socket.py", line 571, in create_connection
raise err
socket.error: [Errno 111] Connection refused
We also tried to ping 172.20.44.148 and we got a response.
Any ideas?
Related
I am trying to run this on Ubuntu
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("10.0.2.15", 5555)) #10.0.2.15 is the Kali IP
s.send("Connected!\n")
data_received = s.recv(1024)
print(data_received)
s.close()
While running
‐v ‐l ‐p 5555 this on kali
But i keep getting this error:
Traceback (most recent call last):
File "client.py", line 4, in <module>
s.connect(("10.0.2.15", 4444))
ConnectionRefusedError: [Errno 111] Connection refused
I'm trying to read fdb files in Ubuntu using firebirdsql:
conn = firebirdsql.connect(host='localhost', database='db.fdb',
user='sysdba', password='masterkey', charset='utf8')
But while connecting, it just said Connection refused.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "~/.local/lib/python3.6/site-packages/firebirdsql/__init__.py", line 94, in connect
conn = Connection(**kwargs)
File "~/.local/lib/python3.6/site-packages/firebirdsql/fbcore.py", line 595, in __init__
self.sock = SocketStream(self.hostname, self.port, self.timeout, cloexec)
File "~/.local/lib/python3.6/site-packages/firebirdsql/socketstream.py", line 46, in __init__
self._sock = socket.create_connection((host, port), timeout)
File "/usr/lib/python3.6/socket.py", line 724, in create_connection
raise err
File "/usr/lib/python3.6/socket.py", line 713, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
the code works well on Windows Server, but on Ubuntu it can't establish the connection, how can I solve it?
In the comments you indicate you don't have a Firebird server installed on your machine. As there is no server listening on localhost port 3050, you get the connection refused error.
That firebirdsql, the driver you're using, is pure Python doesn't mean it can open database files by itself, it means it doesn't use a native library to establish a connection, but that it implements the Firebird TCP/IP wire protocol in Python. You will need a Firebird server (either localhost or remotely) to connect to.
Also: a server normally won't be able to access files in your home directory.
I am using the socket module in python to connect to a remote server at https://vedant-chatroom.glitch.me/chat.html?user=python. This is my code (test.py):
import socket
web_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
web_socket.connect(("https://vedant-chatroom.glitch.me/chat.html?user=python", 443))
After running I get:
Traceback (most recent call last):
File "test.py", line 4, in <module>
web_socket.connect(("https://vedant-chatroom.glitch.me/chat.html?user=python", 443))
socket.gaierror: [Errno 11001] getaddrinfo failed
The remote server is a Node based server which is using the sockets.io package and express.
I can't connect to my host with paramiko. It's no problem to connect throgh a shell though.
My code:
import socket
from paramiko import client
ssh=client.SSHClient()
ssh.load_system_host_keys()
host=socket.gethostbyname("rumo.fritz.box") # works -> host exists
print host
ssh.connect(host,2012,"sshad","MyPassword",timeout=10)
stdin,stdout,stderr=ssh.exec_command("ls -la")
ssh.close()
The error+output:
192.168.178.37
Traceback (most recent call last):
File "./rumo_suspend.py", line 20, in <module>
ssh.connect(host,2012,"sshad","MyPassword",timeout=10)
File "/usr/lib/python2.7/dist-packages/paramiko/client.py", line 296, in connect
sock.connect(addr)
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 113] No route to host
Connecting through a shell:
ssh -p 2012 sshad#rumo.fritz.box
sshad#rumo.fritz.box's password:
Welcome to Linux Mint 17.2 Rafaela (GNU/Linux 3.16.0-031600-generic x86_64)
I am getting this error while trying to connect to mongolab. I am using pymongo-2.8 as mentioned in some of other answers.
connection=MongoClient("mongodb://usr:pass#host:port/data")
StackTrace:
Traceback (most recent call last):
File "C:\chrome_addon\database_update.py", line 5, in <module>
connection=MongoClient("mongodb://user:pass#host:port/data")
File "C:\Python27\lib\site-packages\pymongo\mongo_client.py", line 377, in __init__
raise ConnectionFailure(str(e))
pymongo.errors.ConnectionFailure: [Errno 10061] No connection could be made because the target machine actively refused it
[Finished in 1.6s with exit code 1]
I also tried accessing it with command line, it is failing.
mongo ds031711.mongolab.com:31711/data -u <dbuser> -p <dbpassword>
Stacktrace:
MongoDB shell version: 3.0.5
connecting to: ds031711.mongolab.com:31711/data
2015-10-02T10:40:21.662+0530 W NETWORK Failed to connect to 54.159.76.238:31711
, reason: errno:10061 No connection could be made because the target machine act
ively refused it.
2015-10-02T10:40:21.670+0530 E QUERY Error: couldn't connect to server ds0317
11.mongolab.com:31711 (54.159.76.238), connection attempt failed
at connect (src/mongo/shell/mongo.js:181:14)
at (connect):1:6 at src/mongo/shell/mongo.js:181
exception: connect failed
URI and username,password are correct.