From 74d1008102805a0ec032ccf4beb6357fa0c1f67e Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Tue, 9 May 2023 16:30:35 -0400 Subject: [PATCH] fix: Be able to connect to SQL in containers from CMS 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. We did this in lms/envs/common.py in an earlier change but did not update cms/envs/common.py at that time. --- cms/envs/common.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cms/envs/common.py b/cms/envs/common.py index 77e8fe161d..41ef3f60c2 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -1052,7 +1052,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', @@ -1062,7 +1062,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', @@ -1072,7 +1072,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',