简体   繁体   中英

Django connection mysql error, showing the target computer actively refused

Problem Description:

I am using django to connect to mysql. After clicking and executing, I am telling me that the error is that the target computer actively refuses. I would like to ask what caused this. I checked a lot of information. Basically, the service is not open, but My current mysql on my local computer is turned on.

Error message:

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x000001C834726840>
Traceback (most recent call last):
  File "E:\python\env\webnev\lib\site-packages\pymysql\connections.py", line 582, in connect
    **kwargs)
  File "e:\python\pytho3.6\Lib\socket.py", line 724, in create_connection
    raise err
  File "e:\python\pytho3.6\Lib\socket.py", line 713, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [WinError 10061] Unable to connect because the target computer actively refused.

During handling of the above exception, another exception occurred:

I am not sure if it is related to the version of the module, but as long as I remove the code to add the linked database, this project will run normally.

    DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'test',
        'USER': 'root',
        'PASSWORD': '123456',
        'HOST': '127.0.0.1',
        'POST': '3307',
    },
}

在此处输入图片说明

The reason is: some ports of django are bound, or the port is changed. Try changing the port to 3306. When I changed the port in mysql to 3306, django was changed to the corresponding 3306, and I can connect.

In the config you wrote POST instead of PORT . That might be the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM