Install CockroachDB on Mac

On this page Carat arrow pointing down
Cockroach Labs will stop providing Assistance Support for v22.1 on November 24, 2023. Prior to that date, upgrade to a more recent version to continue receiving support. For more details, see the Release Support Policy.

See Release Notes for what's new in the latest release, v22.1.22. To upgrade to this release from an older version, see Cluster Upgrade.


To deploy a free CockroachDB Cloud cluster instead of running CockroachDB yourself, see the Quickstart.

Install options

Use one of the options below to install CockroachDB.

Use Homebrew

  1. Install Homebrew.

  2. Instruct Homebrew to install CockroachDB:

    $ brew install cockroachdb/tap/cockroach
  3. Keep up-to-date with CockroachDB releases and best practices:

If you previously installed CockroachDB via Homebrew, run brew uninstall cockroach before installing the new version. If you installed using a different method, you may need to remove the binary before installing via Homebrew.

Download the binary

  1. Download the CockroachDB archive for OS X and the supporting libraries that are used to provide spatial features, and copy the binary into your PATH so you can execute cockroach commands from any shell:

    $ curl | tar -xJ && cp -i cockroach-v22.1.22.darwin-10.9-amd64/cockroach /usr/local/bin/

    If you get a permissions error, prefix the command with sudo.

  2. On macOS Catalina (10.15) and above, the first time you run a newly-downloaded version of the cockroach command, a dialog may appear with the message "cockroach" could not be opened because the developer cannot be verified. Cockroach Labs is aware of this issue. To work around this problem and allow the binary to run:

    1. Click Cancel. Do not click Move To Trash. In the terminal, the command exits with an error.
    2. Open System Preferences, then click Security & Privacy.
    3. Click General.
    4. The message "cockroach" was blocked from use because it is not from an identified developer displays. Click Allow Anyway.
    5. Run the cockroach command again.
    6. The message macOS cannot verify the developer of “cockroach”. Are you sure you want to open it? appears. Click Open. The command runs as expected.
  3. Note:

    If you plan to use CockroachDB's spatial features, you must complete the following steps. Otherwise, your installation is now complete.

  4. CockroachDB uses custom-built versions of the GEOS libraries. Copy these libraries to one of the locations where CockroachDB expects to find them.

    By default, CockroachDB looks for external libraries in /usr/local/lib/cockroach or a lib subdirectory of the CockroachDB binary's current directory. If you place these libraries in another location, you must pass the location in the --spatial-libs flag to cockroach start. The instructions below assume the /usr/local/lib/cockroach location.

    1. Create the directory where the external libraries will be stored:

      mkdir -p /usr/local/lib/cockroach
    2. Copy the library files to the directory:

      cp -i cockroach-v22.1.22.darwin-10.9-amd64/lib/libgeos.dylib /usr/local/lib/cockroach/
      cp -i cockroach-v22.1.22.darwin-10.9-amd64/lib/libgeos_c.dylib /usr/local/lib/cockroach/

      If you get a permissions error, prefix the command with sudo.

  5. Verify that CockroachDB can execute spatial queries.

    1. Make sure the cockroach binary you just installed is the one that runs when you type cockroach in your shell:

      which cockroach
    2. Start a temporary, in-memory cluster using cockroach demo:

      cockroach demo
    3. In the demo cluster's interactive SQL shell, run the following command to test that the spatial libraries have loaded properly:

      > SELECT ST_IsValid(ST_MakePoint(1,2));

      You should see the following output:

      (1 row)

      If your cockroach binary is not properly accessing the dynamically linked C libraries in /usr/local/lib/cockroach, it will output an error message like the one below.

      ERROR: st_isvalid(): geos: error during GEOS init: geos: cannot load GEOS from dir "/usr/local/lib/cockroach": failed to execute dlopen
                Failed running "sql"
  6. Keep up-to-date with CockroachDB releases and best practices:

Use Kubernetes

To orchestrate CockroachDB locally using Kubernetes, either with configuration files or the Helm package manager, see Orchestrate CockroachDB Locally with Minikube.

Use Docker

Running a stateful application like CockroachDB in Docker is more complex and error-prone than most uses of Docker. Unless you are very experienced with Docker, we recommend starting with a different installation and deployment method.
  1. Install Docker for Mac. Please carefully check that you meet all prerequisites.

  2. Confirm that the Docker daemon is running in the background:

    $ docker version

    If you do not see the server listed, start the Docker daemon.

  3. Pull the image for the v22.1.22 release of CockroachDB from Docker Hub:

    $ docker pull cockroachdb/cockroach:v22.1.22
  4. Keep up-to-date with CockroachDB releases and best practices:

Build from source

See the public wiki for guidance.

What's next?

By default, each node of a CockroachDB cluster periodically shares anonymous usage details with Cockroach Labs. For an explanation of the details that get shared and how to opt-out of reporting, see Diagnostics Reporting.

Yes No
On this page

Yes No