TLDR Alex encountered problems with Typesense server configuration when setting IP and port using --api-address and --api-port, facing additional problems with CORS and version inequities. Kishore Nallan addressed each point, ultimately finding a bug with the command line parser affecting subsequent commands. The advised workaround was to use `--enable-cors=true`.
There are two address configs. One for api http service which is configured via --api-address and the other is for the raft port that listens on 8107 -- this raft listener uses an internal interface only by default.
ok, but why does TS try to connect to port 80 for a health check on that internal IP?
It shouldn't.
Check the logs to see if there are any errors with api port binding.
If you have SSL configured you need to use https while curling.
This is not something I'm doing, I'm assuming TS does some selfcheck on the wrong IP/PORT: CURL failed. URL:
Oh you see that in the logs?
yup it's in the nohup error log
Are you using clustering?
not in this case no.
nohup ./typesense-server --data-dir=/home/alex/tsdata --api-key=$TYPESENSE_API_KEY --enable-cors \ --api-address 159.203.31.163 \ --api-port=80 \ --log-dir=/home/alex/tsdata/log
Can you add a equals after --api-address flag?
sure
So when I started version 23.rc47 it seemed to ignore the api-address line altogether and bind to * . I didn't see any of the healthcheck errors in the log, but also binding to * might explain that.
Oh okay, we did make one recent change related to this part. I will take a look.
my JS client had a issues connecting to rc47 too
We've other customers using rc47 though. Maybe they don't use custom API address.
Do you have multiple public IPs? Otherwise binding to * is generally fine since you do intend to expose it to internet.
So when I remove the --api-address line then 23.RC47 also ignores --api-port=80 and binds to: *:8108
ApiCall.ts:203 Request #1649419591544: Request to Node 0 failed due to "undefined Network Error" performRequest @ ApiCall.ts:203 ApiCall.ts:205 Request #1649419591544: Sleeping for 0.1s and then retrying request... performRequest @ ApiCall.ts:205 localhost/multi_search?x-typesense-api-key=xyz:1 Failed to load resource: net::ERR_CONNECTION_REFUSED ApiCall.ts:203 Request #1649419591544: Request to Node 0 failed due to "undefined Network Error" performRequest @ ApiCall.ts:203 ApiCall.ts:205 Request #1649419591544: Sleeping for 0.1s and then retrying request... performRequest @ ApiCall.ts:205 localhost/multi_search?x-typesense-api-key=xyz:1 Failed to load resource: net::ERR_CONNECTION_REFUSED
but curl connects just fine
Ok will look at this and get back to you.
We're indeed using the internal IP for an internal health call which happens after a snapshot. But for single node setup, this is not critical and should not affect the server ops. If you just remove the api-address config, Typesense will listen on all interfaces or can also explicitly use: ```--api-address=0.0.0.0```
This is how Typesense has always been, so maybe you've never set this config directly before so didn't notice this problem? Despite that error, single node operations won't be anwyay affected.
Well they are affected: My JS code which comes from your Ecommerce example is no longer able to connect to the single 23.RC47 node. And If I do remove the --api-address line from startup, --api-port=80 is ignored. so 23.RC47 is unable to have a port set unless an --api-address line is in the config
I'm just trying this locally and removing api address has no impact on port. So very strange... Let me try again on a Linux box. Was trying on local mac.
I'm thinking it also might be ignoring the --enable-cors switch as the error I get with RC47 is: Access to XMLHttpRequest at '
Same code works fine with 22.2
nohup ./typesense-server --data-dir=/home/alex/tsdata --api-key=$TYPESENSE_API_KEY --enable-cors \ --api-address=0.0.0.0 \ --api-port=80 \ --log-dir=/home/alex/tsdata/log
Oh right it might be a cors issue.
I could try with a different 23.RC maybe?
Alternatively is there a way to check if cors is enabled? like some sort of display current config command that can be issued to TS?
The response header should have access-control-allow-origin as * I've been AFK so haven't been able to investigate yet, sorry. Will keep you posted.
no rush :wink:
Turned out to be an annoying bug with the command line parser. People were trying to enable cors by send a true value, like `--enable-cors=true` which the argument parsing library that Typesense uses does not support. In trying to fix that, ended up introducing a bug where any flag sent after the enable-cors option becomes interpreted as a value of the enable-cors flag, so when your command is: `--enable-cors --api-address=0.0.0.0` it set the enable-cors value as "`--api-address=0.0.0.0`" :face_palm: Until I fix this parsing issue in a future build, please use `--enable-cors=true` so it's explicit.
Alex
Fri, 08 Apr 2022 09:39:05 UTCIP weirdness with TS server: when I start typesense specifying an IP / PORT like so: --api-address 159.203.31.163 \ --api-port=80 but then I get this: typesense TCP 10.20.0.5:8107 (LISTEN) typesense TCP 159.203.31.163:80 (LISTEN) and in the TS log I can see the 10.x IP being used, while there is nothing listening on that IP on port 80: CURL failed. URL:, Code: 7, strerror: Couldn't connect to server