Skip to content

Fix: Use explicit IPv4 for local connection to avoid DNS hangs#21

Open
onne wants to merge 1 commit into
rawveg:mainfrom
onne:fix/ipv4-resolution
Open

Fix: Use explicit IPv4 for local connection to avoid DNS hangs#21
onne wants to merge 1 commit into
rawveg:mainfrom
onne:fix/ipv4-resolution

Conversation

@onne
Copy link
Copy Markdown

@onne onne commented May 19, 2026

Description

This PR changes the default local connection string from localhost to 127.0.0.1.

Why this approach?

Starting in Node.js 17+, the DNS resolution behavior changed to "Happy Eyeballs", which often resolves localhost to 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

… IPv6 resolution hang

- Set explicit 127.0.0.1 (IPv4) host when not provided.
- Added tests to verify constructor defaults.
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.

Fix: IPv6 localhost resolution hangs in Node.js

1 participant