ElasticsearchException failed to bind service error
Asked Answered
N

4

13

I really wana start elasticsearch for connect opencart. I have set network.host: 0.0.0.0 (also try to my local IP), http.port: 9200, and give executive authority to my new account. I use centOs6, Java 1.8, and don't use root account. I want to use elasticsearch on my server, but I have some issue.

my error log is that

[2019-03-21T18:12:27,970][INFO ][o.e.p.PluginsService     ] [gxhuK_x] loaded module [x-pack-watcher]
[2019-03-21T18:12:27,971][INFO ][o.e.p.PluginsService     ] [gxhuK_x] no plugins loaded
[2019-03-21T18:12:32,061][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [gxhuK_x] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: ElasticsearchException[failed to bind service]; nested: AccessDeniedException[/etc/system-release];
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.6.2.jar:6.6.2]
        at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.6.2.jar:6.6.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:116) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.6.2.jar:6.6.2]
Caused by: org.elasticsearch.ElasticsearchException: failed to bind service
        at org.elasticsearch.node.Node.<init>(Node.java:626) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.node.Node.<init>(Node.java:265) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:212) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:212) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.6.2.jar:6.6.2]
        ... 6 more
Caused by: java.nio.file.AccessDeniedException: /etc/system-release
        at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84) ~[?:?]
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) ~[?:?]
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) ~[?:?]
        at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214) ~[?:?]
        at java.nio.file.Files.newByteChannel(Files.java:361) ~[?:1.8.0_131]
        at java.nio.file.Files.newByteChannel(Files.java:407) ~[?:1.8.0_131]
        at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384) ~[?:1.8.0_131]
        at java.nio.file.Files.newInputStream(Files.java:152) ~[?:1.8.0_131]
        at java.nio.file.Files.newBufferedReader(Files.java:2784) ~[?:1.8.0_131]
        at java.nio.file.Files.readAllLines(Files.java:3202) ~[?:1.8.0_131]
        at java.nio.file.Files.readAllLines(Files.java:3242) ~[?:1.8.0_131]
        at org.elasticsearch.monitor.os.OsProbe.readOsRelease(OsProbe.java:591) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.monitor.os.OsProbe.getPrettyName(OsProbe.java:546) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.monitor.os.OsProbe.osInfo(OsProbe.java:533) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.monitor.os.OsService.<init>(OsService.java:48) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.monitor.MonitorService.<init>(MonitorService.java:47) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.node.Node.<init>(Node.java:397) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.node.Node.<init>(Node.java:265) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:212) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:212) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.6.2.jar:6.6.2]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.6.2.jar:6.6.2]
        ... 6 more

I have installed by tar.gz. and I changed something of config/elasticsearch.yml I didn't change anything else someone know this error? please help me.

# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /var/data/elasticsearch
#
# Path to log files:
#
path.logs: /var/logs/elasticsearch
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
bootstrap.system_call_filter: false
Nidus answered 21/3, 2019 at 11:32 Comment(0)
F
29

You need to make sure that the directory on the host machine is owned by 1000:1000. Run the following command.

sudo chown 1000:1000 <directory you wish to mount>

Source

Failsafe answered 9/7, 2019 at 20:25 Comment(4)
In my mac, I had to run sudo chown -R $UID:$GID PERSISTENT_PATHMisdemeanant
Amit can you please tell me the directory which I wish to mount, I'm a newbie and facing the same issue but I don't know which is the exact path I should use here ?Outstanding
Just adding that 1000 represents the UID and GUID for elasticsearchBethink
Why we need to do this rather than just a docker-compose up command. Any way to void this?Bind
R
1

Please check the following:

  1. Did you create /var/data/elasticsearch and /var/logs/elasticsearch directories in your filesystem?
  2. Did you set the directories above to be writable with your user permission?

Update:

Read the source code of elasticsearch in Github. Link Here It seemed that there some problem when the code is trying to access /etc/system-release. You might to take a look at that file. Also It mentioned that it is fallback for older Red Hat-like OS. So you might want to use another OS if possible.

Rampage answered 22/3, 2019 at 3:14 Comment(4)
Yes, I did it. And I also tried path.data: /home/test/elasticsearch-6.6.2/data/elasticsearch path.logs: /home/test/elasticsearch-6.6.2/logs/elasticsearch but it show same error message.Nidus
I read the source code for elasticsearch. Will update the answer. You might meet other problems but we could see what we could do next.Rampage
ok, I solve this problem. another way. I appreciate your interested. thanks!Nidus
Hi, how was this solved? I'm having the exact same issue after I set a custom path for elasticsearch data. If I comment that line in the yml it works as expected.Melisenda
Z
1

In my variant trouble was in a permissions of data directory. Data directory was not default and changed to /elk-data/

To resolve the issue I make 'chmod -R elasticsearch:wheel /elk-data'

Zofiazoha answered 6/5, 2020 at 4:11 Comment(0)
U
1

I deleted all the files from /var/lib/elasticsearch and it started again.

Undine answered 5/12, 2023 at 11:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.