Skip to content

Error: connect EHOSTUNREACH 192.168.20.12:11434 #4069

Closed
@varris

Description

@varris

Bug Description

getting an error when trying to use an example to connect to a server on my local network.

Reproducible By

My host is 192.168.20.32.
Have Ollama server running on 192.168.20.12.
can confirm it with curl.

curl -v http://192.168.20.12:11434/api/tags
*   Trying 192.168.20.12:11434...
* Connected to 192.168.20.12 (192.168.20.12) port 11434
> GET /api/tags HTTP/1.1
> Host: 192.168.20.12:11434
> User-Agent: curl/8.7.1
> Accept: */*
> 
* Request completely sent off
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
< Date: Thu, 27 Feb 2025 17:33:02 GMT
< Transfer-Encoding: chunked
< 
* Connection #0 to host 192.168.20.12 left intact
{"models":[{"name":"qwen2.5:latest","model":"qwen2.5:latest","modified_at":"2025-02-26T07:31:56-08:00","size":4683087332,"digest":"845dbda0ea48ed749caafd9e6037047aa19acfcfd82e704d7ca97d631a0b697e","details":{"parent_model":"","format":"gguf","family":"qwen2","families":["qwen2"],"parameter_size":"7.6B","quantization_level":"Q4_K_M"}},{"name":"reader-lm:latest","model":"reader-lm:latest","modified_at":"2025-02-26T07:26:55-08:00","size":934966934,"digest":"33da2b9e0afe889906c8cd52bd8957e5bd56747b6b7787206f170bbd5184

use an example from the repo to do the same.

import { request } from 'undici'
(async () => {const {
  statusCode,
  headers,
  trailers,
  body
} = await request('http://192.168.20.12:11434/api/tags')
console.log('response received', statusCode)
console.log('headers', headers)
for await (const data of body) { console.log('data', data) }
console.log('trailers', trailers)})()

and see error

Error: connect EHOSTUNREACH 192.168.20.12:11434 - Local (192.168.20.32:52843)
    at internalConnect (node:net:1115:16)
    at defaultTriggerAsyncIdScope (node:internal/async_hooks:464:18)
    at node:net:1353:9
    at process.processTicksAndRejections (node:internal/process/task_queues:85:11) {
  errno: -65,
  code: 'EHOSTUNREACH',
  syscall: 'connect',
  address: '192.168.20.12',
  port: 11434
}

Node.js v23.5.0

if run ollama locally have no issues

import { request } from 'undici'
(async () => {const {
  statusCode,
  headers,
  trailers,
  body
} = await request('http://localhost:11434/api/tags')
console.log('response received', statusCode)
console.log('headers', headers)
for await (const data of body) { console.log('data', data) }
console.log('trailers', trailers)})()
response received 200
headers {
  'content-type': 'application/json; charset=utf-8',
  date: 'Thu, 27 Feb 2025 17:42:13 GMT',
  'transfer-encoding': 'chunked'
}
data <Buffer 7b 22 6d 6f 64 65 6c 73 22 3a 5b 7b 22 6e 61 6d 65 22 3a 22 64 6f 6c 70 68 69 6e 33 3a 6c 61 74 65 73 74 22 2c 22 6d 6f 64 65 6c 22 3a 22 64 6f 6c 70 ... 11962 more bytes>
trailers {}

Expected Behavior

I should get the same response as curl command

Logs & Screenshots

Environment

$ node --version
v23.5.0

mac os 15.3.1 (24D70)
$ uname -a
Darwin 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan 2 20:22:00 PST 2025; root:xnu-11215.81.4~3/RELEASE_X86_64 x86_64

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions