Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
setting up elasticsearch on your mac with brew

Install va homebrew

If you don't have homebrew installed - get homebrew here

Then run: brew install elasticsearch

Configuration

Update the elasticsearch configuration file in /usr/local/etc/elasticsearch/elasticsearch.yml.

Set the value below to false:

discovery.zen.ping.multicast.enabled: false #(it's true by default)

How to start it

Other sources say to use a removed brew services command. You get it via brew tap gapple/services. Then you're supposed to run brew services start <package-to-start>.

If brew services start elasticsearch doesn't work for you, check the instructions when you run brew info elasticsearch.

Mine says:

To have launchd start elasticsearch at login:
  ln -sfv /usr/local/opt/elasticsearch/*.plist ~/Library/LaunchAgents
Then to load elasticsearch now:
  launchctl load ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist
Or, if you don't want/need launchctl, you can just run:
  elasticsearch --config=/usr/local/opt/elasticsearch/config/elasticsearch.yml

Sources

@FanaHOVA

This comment has been minimized.

Copy link

commented Feb 6, 2017

If you're coming from Google, discovery.zen.ping.multicast.enabled is not an option anymore, it will give you an invalid config and you won't be able to start the server so don't add that line.

@chrishough

This comment has been minimized.

Copy link

commented Mar 22, 2017

Thank you @FanaHOVA, I had the same issue. Once disabled it started up correctly via brew services start elasticsearch

@j3pic

This comment has been minimized.

Copy link

commented Jun 21, 2017

How do you get it to listen on port 9200?

@h0jeZvgoxFepBQ2C

This comment has been minimized.

Copy link

commented Jun 27, 2018

Same question, how do I get it to run on port 9200?

@rawaludin

This comment has been minimized.

Copy link

commented Jul 15, 2018

@lichtamberg its run on port 9200 by default. If you get "connection refused" when tried to connect it, you might have something binding your 127.0.0.1. In my case, I have nginx running. Stopping nginx fix that.

@boutell

This comment has been minimized.

Copy link

commented Jul 31, 2018

brew services is no longer an optional or deprecated beast, it's in the core these days and thank heaven for that.

@JayRizzo

This comment has been minimized.

Copy link

commented Aug 18, 2018

Hi @rawaludin, @boutell and All,

I was getting the Connection Refused Issue too.
I checked and there is a bit more to the issue. In my case,
I had nothing running on port 9200.
So, since I need this to work, I dove from outer space into this rabbit whole. 😜

Error

$ curl -X GET http://localhost:9200/
curl: (7) Failed to connect to localhost port 9200: Connection refused

Note: (curl) works the same with or without the trailing slash.

Did a check

on my mac and it wasn't running?

$ ps ax | grep elasticsearch
67173 s000  S+     0:00.00 grep elasticsearch

So checked homebrew

and restarted the service...

$ brew services restart elasticsearch
Stopping `elasticsearch`... (might take a while)
==> Successfully stopped `elasticsearch` (label: homebrew.mxcl.elasticsearch)
==> Successfully started `elasticsearch` (label: homebrew.mxcl.elasticsearch)

Everything checked out with Homebrew, but still not working...

Looking Deeper,

I located the file to run manually

$ brew ls elasticsearch
/usr/local/Cellar/elasticsearch/6.2.4/libexec/bin/elasticsearch

Running this manually, I got a seemingly hidden error.

$ /usr/local/Cellar/elasticsearch/6.2.4/libexec/bin/elasticsearch
Java HotSpot(TM) 64-Bit Server VM warning: Cannot open file logs/gc.log due to No such file or directory
                                                            ^ Doesn't Exist?!?!?...

Googled it and found the bug report. I left a comment on the PR.

Lastly,

I tried to update this manually myself, trying this but it didn't work:

sudo mkdir /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/db/logs 
sudo touch /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/db/logs/gc.log

As a work around

Just for now to get this to run as I need to run locally for my own development.

  1. GOTO: https://www.elastic.co/downloads/elasticsearch
  2. Download and follow the instructions from the site.
  3. The Command I Ran: $ cd ~/Downloads/elasticsearch-6.3.2 && nohup bin/elasticsearch &>/dev/null &
  4. Did a check & SUCCESS!
     $ curl -X GET http://localhost:9200/
     {
      "name" : "fWD7I7f",
      "cluster_name" : "elasticsearch",
      "cluster_uuid" : "CYepNxx3RhezamsKwxsx8Q",
      "version" : {
        "number" : "6.3.2",
        "build_flavor" : "default",
        "build_type" : "zip",
        "build_hash" : "053779d",
        "build_date" : "2018-07-20T05:20:23.451332Z",
        "build_snapshot" : false,
        "lucene_version" : "7.3.1",
        "minimum_wire_compatibility_version" : "5.6.0",
        "minimum_index_compatibility_version" : "5.0.0"
      },
      "tagline" : "You Know, for Search"
    }

Sharing the knowledge!

Cheers!
JayRizzo

@maarguedas

This comment has been minimized.

Copy link

commented Aug 27, 2018

Hi guy's for brew installation, here some clues:
more ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist # Will give you the log node on the XML
or check with: brew info elasticsearch

@tomchapin

This comment has been minimized.

Copy link

commented Oct 17, 2018

When I simply ran "elasticsearch" (instead of running it as a background service), it bombed due to this error:

java.lang.IllegalArgumentException: unknown setting [discovery.zen.ping.multicast.enabled] please check that any required plugins are installed, or check the breaking changes documentation for removed settings

The official documentation told me to put this line in the "/usr/local/etc/elasticsearch/elasticsearch.yml" file:

discovery.zen.ping.multicast.enabled: false

As it turns out, apparently that line is causing elasticsearch to fail to load.

I simply commented it out, and what do you know, everything started working!

@nyaapass

This comment has been minimized.

Copy link

commented Jan 12, 2019

Hi @JayRizzo, maybe the outdated elasticsearch plugin you have installed caused this problem.

Thanks for your guide to checkout the error.
I also got the Connection Refused Issue in brew services start elasticsearch.

Then I follow your way, simply ran elasticsearch, also got the Cannot open file logs/gc.log error (never mind this),
and when I continue to look through the error message, there is another error exception:

[WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [z0qDgIg] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.IllegalArgumentException: Plugin [analysis-smartcn] was built for Elasticsearch version 6.2.4 but version 6.5.4 is running
	at xxx
Caused by: java.lang.IllegalArgumentException: Plugin [analysis-smartcn] was built for Elasticsearch version 6.2.4 but version 6.5.4 is running
	at xxx

It seems like that I have upgraded elasticsearch by brew upgrade, but I nerver upgrade the analysis-smartcn plugin.
Then I upgrade the plugin by reinstall it:

sudo elasticsearch-plugin remove analysis-smartcn
sudo elasticsearch-plugin install analysis-smartcn

After that, not only simply run elasticsearch but also run brew services start elasticsearch can start elasticsearch successfully.

@demiurg

This comment has been minimized.

Copy link

commented Apr 2, 2019

Hi @JayRizzo and All,

I had the same issue, but I wanted to run the service instead of the downloaded package. Your writeup really helped, and I managed to run ES after editing jvm.options:
/usr/local/etc/elasticsearch/jvm.options

#8:-Xloggc:logs/gc.log
8:-Xloggc:/tmp/logs_gc.log
@mtvillwock

This comment has been minimized.

Copy link

commented Apr 19, 2019

Thank you to @JayRizzo and @demiurg for helping me debug this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.