i face much problems even executing the first lines of code.
I get an java.net.UnknownHostException that says "Der angegebene Host ist unbekannt (
https://xxx.yyyzzz.com
)" which translates to "The specified host is unknown (
https://xxx.yyyzzz.com
)".
I replaced our companies url with xxx.yyyzzz.
Screenshot 2022-05-27 081134
1263×881 75 KB
But actually the server is reachable in the browser, and ping is okay, too:
Screenshot 2022-05-27 082659
1153×253 12.2 KB
How to solve?
Thanks - Enomine
Welcome!
Please don't post images of text as they are hard to read, may not display correctly for everyone, and are not searchable.
Instead, paste the text and format it with
</>
icon or pairs of triple backticks (```), and check the preview window to make sure it's properly formatted before posting it. This makes it more likely that your question will receive a useful answer.
It would be great if you could update your post to solve this.
Here a first guess is that you might have a firewall or a proxy?
public void createClient() throws Exception {
// https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/connecting.html
// Create the low-level client
RestClient restClient = RestClient.builder(new HttpHost("https://gattinger-second.es.europe-west1.gcp.cloud.es.io", 9243)).build();
// Create the transport with a Jackson mapper
ElasticsearchTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());
// And create the API client
ElasticsearchClient client = new ElasticsearchClient(transport);
SearchResponse<Product> search = client.search(s -> s.index("products").query(q -> q.term(t -> t.field("name").value(v -> v.stringValue("bicycle")))), Product.class);
// SearchResponse<Product> search2 = client.search
for (Hit<Product> hit : search.hits().hits()) {
processProduct(hit.source());
private void processProduct(Product p) {
System.out.println("ConnectingText -> process Product -> " + p.getName() + " " + p.getPrice() + " " + p.getSku() + " " + p.getClass());
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
package usage;
public class Product {
private String sku;
private String name;
private double price;
public Product() {
public Product(String sku, String name, double price) {
this.sku = sku;
this.name = name;
this.price = price;
public String getSku() {
return sku;
public void setSku(String sku) {
this.sku = sku;
public String getName() {
return name;
public void setName(String name) {
this.name = name;
public double getPrice() {
return this.price;
public void setPrice(double price) {
this.price = price;
Exception in thread "main" java.io.IOException: Der angegebene Host ist unbekannt (https://gattinger-second.es.europe-west1.gcp.cloud.es.io)
at org.elasticsearch.client.RestClient.extractAndWrapCause(RestClient.java:923)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:299)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:287)
at co.elastic.clients.transport.rest_client.RestClientTransport.performRequest(RestClientTransport.java:146)
at co.elastic.clients.elasticsearch.ElasticsearchClient.search(ElasticsearchClient.java:1502)
at co.elastic.clients.elasticsearch.ElasticsearchClient.search(ElasticsearchClient.java:1519)
at getting_started.ConnectingTest.createClient(ConnectingTest.java:53)
at main.Main.main(Main.java:9)
Caused by: java.net.UnknownHostException: Der angegebene Host ist unbekannt (https://gattinger-second.es.europe-west1.gcp.cloud.es.io)
at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.base/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:933)
at java.base/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1519)
at java.base/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:852)
at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1509)
at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1367)
at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1301)
at org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager$InternalAddressResolver.resolveRemoteAddress(PoolingNHttpClientConnectionManager.java:664)
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager$InternalAddressResolver.resolveRemoteAddress(PoolingNHttpClientConnectionManager.java:635)
at org.apache.http.nio.pool.AbstractNIOConnPool.processPendingRequest(AbstractNIOConnPool.java:474)
at org.apache.http.nio.pool.AbstractNIOConnPool.lease(AbstractNIOConnPool.java:280)
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.requestConnection(PoolingNHttpClientConnectionManager.java:295)
at org.apache.http.impl.nio.client.AbstractClientExchangeHandler.requestConnection(AbstractClientExchangeHandler.java:377)
at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.start(DefaultClientExchangeHandlerImpl.java:129)
at org.apache.http.impl.nio.client.InternalHttpAsyncClient.execute(InternalHttpAsyncClient.java:141)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:295)
... 6 more
Exception in thread "main" co.elastic.clients.elasticsearch._types.ElasticsearchException: [es/search] failed: [security_exception] missing authentication credentials for REST request [/products/_search?typed_keys=true]
at co.elastic.clients.transport.rest_client.RestClientTransport.getHighLevelResponse(RestClientTransport.java:281)
at co.elastic.clients.transport.rest_client.RestClientTransport.performRequest(RestClientTransport.java:147)
at co.elastic.clients.elasticsearch.ElasticsearchClient.search(ElasticsearchClient.java:1502)
at co.elastic.clients.elasticsearch.ElasticsearchClient.search(ElasticsearchClient.java:1519)
at getting_started.ConnectingTest.createClient(ConnectingTest.java:53)
at main.Main.main(Main.java:9)