Unable to connect to CrateDB from another host

Hi,

I’m using Crate in a pretty simple setup - a single host, on a Raspberry Pi, nothing more.

I can successfully connect to it from localhost using http. I’m trying to figure out the configuration to allow me to connect from another host.

I can’t access the admin UI from another host, or connect using the crate python module.

I’ve been looking through crate.yml to try to identify what to change to allow this, and can’t figure it out.

My first thought was that I needed to set

network.host: 192.168.0.200

However, this failed with:

Mar 26 11:09:04 raspberrypi crate[3595]: [2024-03-26T11:09:04,942][INFO ][o.e.n.Node               ] [Höfats] starting ...
Mar 26 11:09:05 raspberrypi crate[3595]: [2024-03-26T11:09:05,017][INFO ][psql                     ] [Höfats] publish_address {192.168.0.200:5432}, bound_addresses {192.168.0.200:5432}
Mar 26 11:09:05 raspberrypi crate[3595]: [2024-03-26T11:09:05,029][INFO ][o.e.h.n.Netty4HttpServerTransport] [Höfats] publish_address {192.168.0.200:4200}, bound_addresses {192.168.0.200:4200}
Mar 26 11:09:05 raspberrypi crate[3595]: [2024-03-26T11:09:05,040][INFO ][o.e.t.TransportService   ] [Höfats] publish_address {192.168.0.200:4300}, bound_addresses {192.168.0.200:4300}
Mar 26 11:09:05 raspberrypi crate[3595]: [2024-03-26T11:09:05,300][INFO ][o.e.b.BootstrapChecks    ] [Höfats] bound or publishing to a non-loopback address, enforcing bootstrap checks
Mar 26 11:09:05 raspberrypi crate[3595]: ERROR: [1] bootstrap checks failed

I get the same error with using _wlan0_ or _site_

Thinking that this wasn’t the issue, I then tried various options in the auth section of the config, changing the whole auth section to look like this:

auth:
  host_based:
    config:
      0:
        user: crate
        address: _local_
        method: trust
      1:
        user: my_user
        address: 192.168.0.201
        method: trush
      99:
        method: password

I also tried with the new section being password as the method.

None of these have worked for me - when I try to connect from another host, I get a timeout every time (using exactly the same script (apart from the host, username and password) to test).

Any tips as to how to allow this?

Thanks

EDIT: I found another thread on here that mentioned that you could set multiple network.host values, so I tried doing:

network.host: _local_, _wlan0_

I tried this (the comment in the config file, and the documentation don’t make it clear that multiple values are allowed), but got this error in the log (similar to above):

Mar 26 11:33:18 raspberrypi crate[4928]: [2024-03-26T11:33:18,153][INFO ][psql                     ] [Krofička] publish_address {192.168.0.200:5432}, bound_addresses {192.168.0.200:5432}, {[::1]:5432}, {127.0.0.1:5432}, {[fe80::1914:7916:eb39:e149]:5432}
Mar 26 11:33:18 raspberrypi crate[4928]: [2024-03-26T11:33:18,189][INFO ][o.e.h.n.Netty4HttpServerTransport] [Krofička] publish_address {192.168.0.200:4200}, bound_addresses {192.168.0.200:4200}, {[::1]:4200}, {127.0.0.1:4200}, {[fe80::1914:7916:eb39:e149]:4200}
Mar 26 11:33:18 raspberrypi crate[4928]: [2024-03-26T11:33:18,200][INFO ][o.e.t.TransportService   ] [Krofička] publish_address {192.168.0.200:4300}, bound_addresses {192.168.0.200:4300}, {[::1]:4300}, {127.0.0.1:4300}, {[fe80::1914:7916:eb39:e149]:4300}
Mar 26 11:33:18 raspberrypi crate[4928]: [2024-03-26T11:33:18,430][INFO ][o.e.b.BootstrapChecks    ] [Krofička] bound or publishing to a non-loopback address, enforcing bootstrap checks
Mar 26 11:33:18 raspberrypi crate[4928]: ERROR: [1] bootstrap checks failed

If you are trying to connect to CrateDB via HTTP from outside localhost you need to set up CORS.

In docker:
docker run -p 4200:4200 crate -Chttp.cors.enabled=true -Chttp.cors.allow-origin=192.168.88.257

Change the IP for the one you are trying to connect from, alternatively for testing purposes you can do ‘*’ and accept all.

Thanks.

Is this something that I should be able to set in crate.yml instead of running on the command-line (I’m not running it through Docker)

I tried running it with the modified command-line, and still couldn’t connect.

Yeah, in here you can see how we set other http options, set them here without the ‘-C’, crate/app/src/main/dist/config/crate.yml at 921b53f428e2e65e9c57d10e23872a0d3fb5d022 · crate/crate · GitHub

Thanks - I tried setting the cors settings like that and on the command-line, and I still couldn’t connect from another host.

Hi,

If you are binding to a network reachable IP address, CrateDB performs a number of bootstrap checks during startup.

Could you check the settings from Bootstrap checks — CrateDB: Guide ?

I’ve just realised this and have been working through it.

My actual boostrap error (which I didn’t include above) was:

[1]: initial heap size [268435456] not equal to maximum heap size [2113929216]; this can cause resize pauses and prevents mlockall from locking the entire heap. Set the heap size via the CRATE_HEAP_SIZE environment variable. See https://crate.io/docs/crate/howtos/en/latest/performance/memory.html

I’ve now changed my commandline to include -Xms2048m -Xmx2048m (previously it just had -Xms256m) and it appears to work

Thanks

And, for future reference, my actual fix in systemd was to edit my crate.service to add in:

Environment="CRATE_HEAP_SIZE=2048m"
1 Like