Running on --host flag instead of --insecure Error

Running a web application and anyways it can connect to cockroach successfully. everything works fine with the “–insecure” flag but when changed to “–host” cockroach launches succesfully. but I now get error below.

how do I go about fixing this error?

=== error ===
could not connect to server: Connection refused Is the server running on host “localhost” (127.0.0.1/32) and accepting TCP/IP connections on port 26257?

=== running processes ===

root 737 0.0 0.2 10428 2020 - Is 17:46 0:00.00 daemon: /usr/local/bin/cockroach[738] (daemon)
cockroach 738 0.0 3.6 72132 36168 - I 17:46 0:00.14 /usr/local/bin/cockroach start --host --store=path=/home/cockroach

Thanks,
Diego

--host takes a value: use it like --host=cockroach1.mydomain.com. It’s not a direct alternative to --insecure; you’d usually use the same --host value for both secure and insecure mode. If cockroach start --insecure does what you want, you’d change it to secure mode by just removing --insecure and putting certificates in the right place (or adding --certs-dir)

--host causes the process to bind to the real network, not the “loopback” network interface used by localhost. When you pass --host to the server, you generally have to use --host on the client processes too to tell them where to connect (even if they’re running on the same machine).

You may want to use --advertise-host instead. This allows the server to listen on all network interfaces but still use an alternative hostname for broadcasting to other nodes.