Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX]: Database Connection Issue by Hostname Resolution During Setup #6075

Closed

Conversation

JiyaGupta-cs
Copy link
Contributor

@JiyaGupta-cs JiyaGupta-cs commented Dec 20, 2024

What this PR does

This pull request addresses an issue encountered during the setup process on Fedora using Docker, where the database connection fails due to hostname resolution issues. The error occurs when the system is unable to resolve the required hostname, leading to the failure of the setup process.

Fixes #6074

Changes Introduced:

Added a script that automatically resolves the hostname by ensuring proper network mapping, allowing the database connection to be established successfully.
This script ensures that the system can correctly resolve the hostname and connect to the database without errors.
Can be invoked by bash ./update_hosts.sh

Explanation:

The issue arises because the necessary host entries are not present in the /etc/hosts file
When the system attempts to resolve an address, it fails to locate the corresponding hostname in the local resolution file and subsequently defaults to querying the network gateway to determine if the address exists.
To address this, I have implemented a script to automate the addition of host entries to the /etc/hosts file. This ensures that the hostname resolution process can efficiently locate and map the desired addresses locally without needing to fallback to external network queries.
The current Docker Compose file lacks the necessary configurations to locate the mappings effectively.

Key Cases Handled:

  • Container Running:
    If the Docker container is up, the script updates the /etc/hosts file with the new IP address, ensuring correct hostname resolution.

  • Container Restarted:
    If the Docker container is restarted and the IP address changes, the script checks for the old address and updates it with the new IP address in /etc/hosts.

  • Container Down:
    If the Docker container is down, the update_hosts.sh script removes the corresponding address from the /etc/hosts file to prevent stale entries.

  • No Duplicate Entries:
    The script ensures that there are no duplicate IP addresses for the same hostname in the /etc/hosts file, maintaining clean mappings.

Testing:

Verified that running the script ensures successful hostname resolution.
Confirmed that the database connection is now established properly, and the setup process completes without errors.

Remark

This PR solves the database connection issue for Fedora

Other Questions:

This also needs updation in the Docker docs
So should I make that also ?

@JiyaGupta-cs JiyaGupta-cs changed the title [FIX]: Database Connection Issue by Resolving Hostname Resolution During Setup [FIX]: Database Connection Issue by Hostname Resolution During Setup Dec 20, 2024
@JiyaGupta-cs
Copy link
Contributor Author

Video Demonstration of setting up with and without script

VID_20241221_034417_795.mp4

@ragesoss
Copy link
Member

Yes, please update the docker.md file along with this. I don't use Docker for my dev environment, but this looks like a reasonable script.

@JiyaGupta-cs
Copy link
Contributor Author

Yes, please update the docker.md file along with this. I don't use Docker for my dev environment, but this looks like a reasonable script.

Sure, I will update that also.

@JiyaGupta-cs
Copy link
Contributor Author

I closed this by mistake
Will open a new one for the same issue @ragesoss

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Database Connection Error: During Setup using Docker
2 participants