janhq/jan

bug: Cannot access Nitro on port 3928 in Docker from Host

Closed this issue · 2 comments

Describe the bug
I should be able to curl http://localhost:3928/v1/embeddings from the host, but it isn't possible because nitro binds to port 127.0.0.1

Steps to reproduce
Steps to reproduce the behavior:

  1. Run docker-compose up
  2. Start a model with a call to curl -X PUT http://localhost:1337/v1/models/<model>/start -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{}'
  3. Try to this command: curl http://localhost:3928/v1/embeddings -H 'Content-Type: application/json' -d { "input": "why hardcode the host like this?", "encoding_format": "float" }

Expected behavior
I expect embeddings

Additional context
If you docker exec -it into the docker and run the following:

apt-get update
apt-get install lsof
lsof -Pi4 | grep 3928

You'll see nitro keep binding to localhost, not 0.0.0.0

If we change the line here from:

export const LOCAL_HOST = '127.0.0.1'

to:

export const LOCAL_HOST = process.env.NITRO_HOST || '127.0.0.1'

Then we can have the flexibility needed to account for Docker setups by setting NITRO_HOST in the environments block of docker-compose.yml to 0.0.0.0

Nito is an embedded process and not supposed to be exposed to external process due to security concern, i would suggest you just use janAPI server directly on Jan UI