Typesense js seems to have issues connecting to the server when using localhost as the host in the configuration.
Steps to reproduce
Install typesense 0.23.1 .deb file on Ubuntu 22.04.1 LTS, Keep all config values as default. Install typesense-js from npm. Try to connect to the server using "host": "localhost".
Expected Behavior
Connection should happen.
Actual Behavior
Get this error message instead. ECONNREFUSED connect ECONNREFUSED ::1:8108
Additional info
When in the terminal curl http://localhost:8108/health returns {"ok":true}
To get it working I had to edit /etc/typesense/typesense-server.ini and change the api-address to the public IP of my server and use the same public IP address in my typsense-js configuration as the host. Earlier I could use the default typesense-server.ini and localhost in the js config.
It looks like localhost resolves to ::1 on your computer, which is ipv6. But Typesense only supports ipv4. So you would have to use 127.0.0.1 as your hostname to connect to Typesense running locally.
Description
Typesense js seems to have issues connecting to the server when using localhost as the host in the configuration.
Steps to reproduce
Install typesense 0.23.1 .deb file on Ubuntu 22.04.1 LTS, Keep all config values as default. Install typesense-js from npm. Try to connect to the server using "host": "localhost".
Expected Behavior
Connection should happen.
Actual Behavior
Get this error message instead. ECONNREFUSED connect ECONNREFUSED ::1:8108
Additional info
When in the terminal
curl http://localhost:8108/health
returns{"ok":true}
To get it working I had to edit
/etc/typesense/typesense-server.ini
and change theapi-address
to the public IP of my server and use the same public IP address in my typsense-js configuration as thehost
. Earlier I could use the defaulttypesense-server.ini
andlocalhost
in the js config.Metadata
Typesense Version: 0.23.1
OS: Ubuntu 22.04.1 LTS
node: 18.12.1