0

I write code on my local machine and then use github to transfer the code to my Amazon AWS EC2 server, I am using AWS Route53 to connect to a domain name and AWS RDS for database (started using recently, few days ago).

In my previous code I was using Hostinger's remote mysql capability for a hosted database which was working fine, I deployed the code on AWS EC2 server and tested, however, when I created MySql database using RDS and updated its details in the settings.py the application is still being run using the old Hostinger's database settings only.

I have tried the following things:

  1. deleting all the cache files,
  2. removing all migrations files and creating migrations once again,
  3. checked settings.py (database configuration settings) multiple times
  4. Restarted the EC2 instance, restarted supervisor, gunicorn, nginx
  5. Deleted the RDS database and created one more and updated its respective settings in settings.py

To my surprise, for some reason it is still working on the old database, I am not able to figure out where exactly is it picking up the details of the old database and why is the latest settings.py file not being loaded in real time?

11
  • is there multiple settings.py file can you confirm that in your local?? and please also check if you have setup any varaibles in github pipelines Commented Aug 18, 2024 at 4:17
  • there is only one settings.py file in my local as well as on EC2 server. Secondly, there are no environment variables being used to point to settings.py Commented Aug 18, 2024 at 4:19
  • can you sahre your settings.py after redacting the credentials Commented Aug 18, 2024 at 4:21
  • Please let me know if the following file is accessible to you: drive.google.com/file/d/1dxGJvIEeO7dQj9FLGalTi6KMn8eIWRDQ/… Commented Aug 18, 2024 at 4:31
  • Can you check your manage.py file and check for a line like this os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'YOUR_PROJECT_NAME.settings') YOUR_PROJECT_NAME should be correct here. Then run python manage.py runserver 0.0.0.0:8000 instead of gunicorn and see if its taking the right settings.py Commented Aug 18, 2024 at 5:07

1 Answer 1

1

During an earlier git pull, the settings.py file was inadvertently pulled from project_name/project_name/settings.py to project_name/settings.py. This resulted in multiple copies of the file, and I mistakenly made edits to the latter one, which did not affect the original settings file.

I have since amended the correct settings.py file, and the changes are now properly reflected.

Thank you, @nabinsademba and @ArunT, for your assistance. I appreciate your time and apologize for any inconvenience caused.

The issue has been resolved. Thank you once again!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.