MySQL Forums
Forum List  »  Connector/Python

ConnectionRefusedError: WinError 10061 Python
Posted by: Sam Slusky
Date: May 26, 2020 04:53AM

Good Morning,

Set MySQL up on my computer with seemingly no problem, Created a database "servers" and connected to it on According to the Server Status pane, the server is running. According to the PHP code and through testing the connection in the Connect to Database view I'm reasonably confident that the following connection information is accurate (with the password not being included


That being said, when I try and connect via the following python script, I get an error:

##Python 3.7
import mysql.connector
from mysql.connector import errorcode

mydb = mysql.connector.connect(
port ="3306",
except mysql.connector.Error as err:
if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
print("Something is wrong with your user name or password")
elif err.errno == errorcode.ER_BAD_DB_ERROR:
print("Database does not exist")

print (mydb)

ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

I've tried changing firewall settings, I've tried changing python versions and i've removed and re-installed mysql-connector. I've seen variations of this question pop up but nobody seems to have provided an answer, or confirmed the answer works. I'm looking for suggestions/advice on how I might resovle this. I'll post the full traceback below this.

Best regards,
- Sam

Traceback (most recent call last):
File "C:\Python37\lib\", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Python37\lib\", line 85, in _run_code
exec(code, run_globals)
File "c:\Users\sam\.vscode\extensions\ms-python.python-2020.5.80290\pythonFiles\lib\python\debugpy\wheels\debugpy\launcher\", line 95, in <module>
File "c:\Users\sam\.vscode\extensions\ms-python.python-2020.5.80290\pythonFiles\lib\python\debugpy\wheels\debugpy\launcher\", line 51, in main
launcher.connect(host, port)
File "c:\Users\sam\.vscode\extensions\ms-python.python-2020.5.80290\pythonFiles\lib\python\debugpy\wheels\debugpy\launcher/../..\debugpy\launcher\", line 34, in connect
sock.connect((host, port))
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

Options: ReplyQuote

Written By
ConnectionRefusedError: WinError 10061 Python
May 26, 2020 04:53AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.