From c3dc07ed7d83cc7cf32bd3fa96c9ed6d5f9cae03 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Mon, 8 May 2023 10:07:00 -0400 Subject: [PATCH] fix: Be able to connect to SQL in containers. By default if you use `localhost` as the `HOST` value for mysql, it tries to connect to a file socket on disk rather than trying to connect to the loopback hostname. This prevents us from running MySQL in a container while running the LMS on your local machine. Setting the host to `127.0.0.1` forces the SQL connection to go over TCP instead. This allows you to map your container port to your localhost without any issues. --- lms/envs/common.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lms/envs/common.py b/lms/envs/common.py index e3e486108f..e8a9710752 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -1640,7 +1640,7 @@ DATABASES = { 'ATOMIC_REQUESTS': True, 'CONN_MAX_AGE': 0, 'ENGINE': 'django.db.backends.mysql', - 'HOST': 'localhost', + 'HOST': '127.0.0.1', 'NAME': 'edxapp', 'OPTIONS': {}, 'PASSWORD': 'password', @@ -1650,7 +1650,7 @@ DATABASES = { 'read_replica': { 'CONN_MAX_AGE': 0, 'ENGINE': 'django.db.backends.mysql', - 'HOST': 'localhost', + 'HOST': '127.0.0.1', 'NAME': 'edxapp', 'OPTIONS': {}, 'PASSWORD': 'password', @@ -1660,7 +1660,7 @@ DATABASES = { 'student_module_history': { 'CONN_MAX_AGE': 0, 'ENGINE': 'django.db.backends.mysql', - 'HOST': 'localhost', + 'HOST': '127.0.0.1', 'NAME': 'edxapp_csmh', 'OPTIONS': {}, 'PASSWORD': 'password',