Fix: Use explicit IPv4 for local connection to avoid DNS hangs#21
Open
onne wants to merge 1 commit into
Open
Conversation
… IPv6 resolution hang - Set explicit 127.0.0.1 (IPv4) host when not provided. - Added tests to verify constructor defaults.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR changes the default local connection string from
localhostto127.0.0.1.Why this approach?
Starting in Node.js 17+, the DNS resolution behavior changed to "Happy Eyeballs", which often resolves
localhostto the IPv6 loopback (::1) first. Because local Ollama instances typically only listen on the IPv4 loopback (127.0.0.1), this causes Node.js connection attempts to hang or fail until the IPv6 attempt times out.By explicitly setting the default host to
127.0.0.1, we bypass DNS resolution entirely, ensuring immediate and reliable connections to the local Ollama daemon across all Node environments.Resolves #15