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.
Related
I am running a Docker container on Windows which is basically made from Ubuntu Image with some add-ons(asterisk pbx). When I try to connect to it(I take IPv4 from ipconfig's "WSL") with python socket:
import socket
a = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
a.connect(('172.19.96.1', 5038))
I get
Traceback (most recent call last):
File "E:\Projects\project\test.py", line 43, in <module>
a.connect(('172.19.96.1', 5038))
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
How do I connect to it? I am 100% sure my container is listening to 0.0.0.0:5038 as I can connect to it from inside of the container.
btw I tried to change '172.19.96.1' to '127.0.0.1' and 'localhost' both, but all the same I'm getting that error.
I accidently remove some folders from linux that have informations from DB, idk what i did, but i cant do my Dags work. Look the error:
Broken DAG: [/home/airflow/airflow/dags/etlSFX.py] Traceback (most recent call last):
File "src/pymssql/_mssql.pyx", line 1817, in pymssql._mssql.maybe_raise_MSSQLDatabaseException
File "src/pymssql/_mssql.pyx", line 1834, in pymssql._mssql.raise_MSSQLDatabaseException
pymssql._mssql.MSSQLDatabaseException: (20009, b'DB-Lib error message 20009, severity 9:\nUnable to connect: Adaptive Server is unavailable or does not exist (192.168.100.36)\nNet-Lib error during Connection refused (111)\nDB-Lib error message 20009, severity 9:\nUnable to connect: Adaptive Server is unavailable or does not exist (192.168.100.36)\nNet-Lib error during Connection refused (111)\n')
I'm trying to connect Python from a Mac to a MySql database that is running on a Raspberry Pi 4 with Ubuntu Server LTS 20.04 installed where both machines are on my LAN. Currently I have MySql Workbench on the Mac and am able to access the database via a Standard TCP/IP connection using SSH. No problem accessing the server via the Terminal over SSH or logging into the database in question.
I'm running Python 3.8.5 on the Mac and the latest version of MySQL Server on the Ubuntu Server installed on the RPi4.
The issue comes up when I write the connection code in a Python file, and attempt to run it via the Terminal. Here is the error I am getting (spaces are mine):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mysql/connector/connection_cext.py", line 216, in _open_connection
self._cmysql.connect(**cnx_kwargs)
_mysql_connector.MySQLInterfaceError: Access denied for user '***'#'localhost' (using password: YES)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "testdb1PYTHON.py", line 3, in <module>
mydb = mysql.connector.connect(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mysql/connector/__init__.py", line 264, in connect
return CMySQLConnection(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mysql/connector/connection_cext.py", line 80, in __init__
self.connect(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mysql/connector/abstracts.py", line 966, in connect
self._open_connection()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mysql/connector/connection_cext.py", line 218, in _open_connection
raise errors.get_mysql_exception(msg=exc.msg, errno=exc.errno,
mysql.connector.errors.ProgrammingError: 1045 (28000): Access denied for user```
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?
I am new to paho-mqtt. I was trying to publish a topic using my localhost and I encountered the following error :
Traceback (most recent call last):
File "server.py", line 10, in <module>
client1.connect(host,port,keepalive)
File "/usr/local/lib/python2.7/dist-packages/paho_mqtt-1.3.1-py2.7.egg/paho/mqtt/client.py", line 768, in connect
return self.reconnect()
File "/usr/local/lib/python2.7/dist-packages/paho_mqtt-1.3.1-py2.7.egg/paho/mqtt/client.py", line 895, in reconnect
sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))
File "/usr/lib/python2.7/socket.py", line 575, in create_connection
raise err
socket.error: [Errno 111] Connection refused
My python code is below :
import paho.mqtt.client as paho
port=1883
host = "localhost"
keepalive = 60
def on_publish(client,userdata,result):
print("data published \n")
pass
client1= paho.Client("control1")
client1.on_publish = on_publish
client1.connect(host,port,keepalive)
ret= client1.publish("Robot","Robot 1 move_left")
When I run the same code with iot.eclipse.org as host then it works fine. Any help would be highly appreciated.
I was facing the same issue.
The solution was to install a local MQTT broker.
http://www.steves-internet-guide.com/install-mosquitto-linux/
The exposed docker port for mqtt is usually different than 1883.
I use the official eclipse mosquitto docker and the run example on their page is something like:
sudo docker run -it -p 11883:1883 -p 9001:9001 eclipse-mosquitto
therefore the client should connect to port 11883
client.connect(broker_address, 11883)