django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1' ([Errno 111] Connection refused)")
时间: 2023-12-18 14:07:20 浏览: 66
This error message indicates that the Django application is unable to connect to the MySQL server running on the local machine at IP address 127.0.0.1 (also known as localhost). The connection is being refused, which could be due to a number of reasons such as:
- The MySQL server is not running
- The MySQL server is running on a different port than the default (3306)
- The MySQL server is not configured to accept connections from the Django application
- There is a firewall or network issue preventing the connection
To resolve the issue, you can try the following:
1. Make sure the MySQL server is running and listening on the correct port (usually 3306). You can check this by running "sudo systemctl status mysql" on the command line.
2. Check the MySQL server's configuration file (my.cnf) to ensure that it is set up to accept connections from the Django application's host and port.
3. Ensure that any firewalls or network security groups are configured to allow traffic on the MySQL server's port.
4. Try connecting to the MySQL server from another application or client to see if the issue is specific to Django.
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)