# Net core 2.1 elasticsearch working in development, it doesn't work in release

**URL:** <https://discuss.elastic.co/t/net-core-2-1-elasticsearch-working-in-development-it-doesnt-work-in-release/191503>\
**Category:** Elasticsearch\
**Created:** [July 21, 2019, 3:45am UTC](https://discuss.elastic.co/t/net-core-2-1-elasticsearch-working-in-development-it-doesnt-work-in-release/191503 "2019-07-21T03:45:47Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ilyoskhuja](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ilyoskhuja/32/47524_2.png) [@Ilyoskhuja](https://discuss.elastic.co/u/Ilyoskhuja)\
**Post date:** [July 21, 2019, 3:45am UTC](https://discuss.elastic.co/t/net-core-2-1-elasticsearch-working-in-development-it-doesnt-work-in-release/191503/1 "2019-07-21T03:45:48Z")

</div>

net core 2.1 elasticsearch working in development, it doesn't work in release,  
this is my elasticsearch class

```
    {public static class ElasticsearchExtensions
    {
        public static void AddElasticsearch(
            this IServiceCollection services, IConfiguration configuration)
        {
            var defaultIndex ="honadonz";
           
       
            var settings = new ConnectionSettings(new Uri("https://711e0c87a+++++++=========dc2528152891.us-east-1.aws.found.io:9243"))
                .DefaultIndex(defaultIndex)
                .BasicAuthentication("elastic", "q1vqu++++++++yfV7RFS5WR6");

            // AddDefaultMappings(settings);

            var client = new ElasticClient(settings);

            services.AddSingleton<IElasticClient>(client);

            CreateIndex(client, defaultIndex);
        }

        private static void AddDefaultMappings(ConnectionSettings settings)
        {
            settings
                .DefaultMappingFor<ElasticSearchModel>(m => m);
                   
        }

        private static void CreateIndex(IElasticClient client, string indexName)
        {
            var createIndexResponse = client.CreateIndex("honadonz", c => c
                          .Mappings(m => m.Map<ElasticSearchModel>(mm => mm
                         .AutoMap()
                            ))
                            .RequestConfiguration(r => r
                            .DisableDirectStreaming()
    )
                  );

                   Console.WriteLine("Writeline is :" + createIndexResponse);
        }
    }
}

```

I use Elasticsearch version 6.8.1 in [cloud.elastic.co](http://cloud.elastic.co) and nest 6.8.0

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [July 21, 2019, 11:07pm UTC](https://discuss.elastic.co/t/net-core-2-1-elasticsearch-working-in-development-it-doesnt-work-in-release/191503/2 "2019-07-21T23:07:13Z")

</div>

> [@Ilyoskhuja](#):
>
> net core 2.1 elasticsearch working in development, it doesn't work in release,

What doesn't work? What exception or error do you get?

---

<div class="post-metadata">

**Author:** ![Ilyoskhuja](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ilyoskhuja/32/47524_2.png) [@Ilyoskhuja](https://discuss.elastic.co/u/Ilyoskhuja)\
**Post date:** [July 22, 2019, 12:51pm UTC](https://discuss.elastic.co/t/net-core-2-1-elasticsearch-working-in-development-it-doesnt-work-in-release/191503/3 "2019-07-22T12:51:14Z")

</div>

I am trying to find more error details, but now it only shows (status: 400, statusText: "Bad Request)

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [July 22, 2019, 1:25pm UTC](https://discuss.elastic.co/t/net-core-2-1-elasticsearch-working-in-development-it-doesnt-work-in-release/191503/4 "2019-07-22T13:25:49Z")

</div>

Take a look at the documentation about [logging more details using `OnRequestCompleted` or a proxy](https://www.elastic.co/guide/en/elasticsearch/client/net-api/7.x/logging.html), and making them [available on `DebugInformation`](https://www.elastic.co/guide/en/elasticsearch/client/net-api/7.x/debug-information.html)

---

<div class="post-metadata">

**Author:** ![Ilyoskhuja](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ilyoskhuja/32/47524_2.png) [@Ilyoskhuja](https://discuss.elastic.co/u/Ilyoskhuja)\
**Post date:** [July 28, 2019, 7:59am UTC](https://discuss.elastic.co/t/net-core-2-1-elasticsearch-working-in-development-it-doesnt-work-in-release/191503/5 "2019-07-28T07:59:34Z")

</div>

Error :

2019-07-28 09:54:38.745 +02:00 [Warning] Invalid NEST response built from a unsuccessful () low level call on POST: /honadon/\_search?typed\_keys=true

# Audit trail of this API call:

- [1] BadRequest: Node: [https://82+++++++4a5991cb155b5877928e.europe-west1.gcp.cloud.es.io:9243/](https://82+++++++4a5991cb155b5877928e.europe-west1.gcp.cloud.es.io:9243/) Took: 00:00:00.0034149

# OriginalException: System.Net.Http.HttpRequestException: An attempt was made to access a socket in a way forbidden by its access permissions ---\> System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions

at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)  
--- End of inner exception stack trace ---  
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)  
at System.Threading.Tasks.ValueTask`1.get_Result() at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Threading.Tasks.ValueTask`1.get\_Result()  
at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask) at System.Threading.Tasks.ValueTask`1.get\_Result()  
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)  
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)  
at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)  
at Elasticsearch.Net.HttpConnection.Request[TResponse](RequestData requestData)

---

<div class="post-metadata">

**Author:** ![Ilyoskhuja](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ilyoskhuja/32/47524_2.png) [@Ilyoskhuja](https://discuss.elastic.co/u/Ilyoskhuja)\
**Post date:** [July 28, 2019, 4:54pm UTC](https://discuss.elastic.co/t/net-core-2-1-elasticsearch-working-in-development-it-doesnt-work-in-release/191503/6 "2019-07-28T16:54:18Z")

</div>

I wrote to support, company which I take hosting plan, and they answer to me

> Dear Customer,
> 
> The issue is due to your website calls an external API.Please use "Outgoing Port" to open the connection for this API.  
> [SmarterASP.net](https://www.smarterasp.net/support/kb/a1916/how-to-enable-outgoing-port-from-your-hosting-control-panel.aspx?KBSearchID=592490)
> 
> Thank you.  
> Ilysokhuja:  
> why i need this, i havent problem with AWS, why same service from [cloud.elastic.co](http://cloud.elastic.co) has error like this, why i should change something, if tomorrow i change my elastic to another cloud , should i change everytime, i think this is not good solution
> 
> Joy (staff)  
> 7/28/2019 4:47:46 AM Dear Customer,
> 
> For security reason, we only allow 80 and 443 ports to third party server. If you are using different ports to connect to third party service, you will need to open outgoing port from our server to the specific server port.
> 
> If you changed the third party server to another one in the further, you will then need update your outgoing port setting to the new server ip.
> 
> Thank you.
> 
> Dear Customer,
> 
> You will need to upgrade your hosting account to our .net premium plan, so you can enable spacial port to the remote server.
> 
> Thank you.

Why [cloud.elastic.co](http://cloud.elastic.co) cant work like AWS?

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [July 29, 2019, 1:09am UTC](https://discuss.elastic.co/t/net-core-2-1-elasticsearch-working-in-development-it-doesnt-work-in-release/191503/7 "2019-07-29T01:09:30Z")

</div>

> [@Ilyoskhuja](#):
>
> Why [cloud.elastic.co](http://cloud.elastic.co) cant work like AWS?

I don't know what is meant by this statement. There are [many differences between Elastic's Elasticsearch Service and AWS](https://www.elastic.co/aws-elasticsearch-service).

It sounds like the issue is related to your hosting provider not allowing outbound connections on port 9243, which should be configurable on the hosting provider. [**Note that port 443 is also supported for HTTPS**](https://www.elastic.co/guide/en/cloud/current/ec-getting-started-connect.html).

---

<div class="post-metadata">

**Author:** ![Ilyoskhuja](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ilyoskhuja/32/47524_2.png) [@Ilyoskhuja](https://discuss.elastic.co/u/Ilyoskhuja)\
**Post date:** [July 29, 2019, 5:33pm UTC](https://discuss.elastic.co/t/net-core-2-1-elasticsearch-working-in-development-it-doesnt-work-in-release/191503/8 "2019-07-29T17:33:01Z")

</div>

Now its working , after enabled port from hosting provider.

---

<div class="post-metadata">

**Author:** ![Ilyoskhuja](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ilyoskhuja/32/47524_2.png) [@Ilyoskhuja](https://discuss.elastic.co/u/Ilyoskhuja)\
**Post date:** [August 6, 2019, 6:13pm UTC](https://discuss.elastic.co/t/net-core-2-1-elasticsearch-working-in-development-it-doesnt-work-in-release/191503/9 "2019-08-06T18:13:12Z")

</div>

Today I changed my account [cloud.elastic.co](http://cloud.elastic.co)(I am using different URL), I didnt change any code for search, and create new index same version as before (v7.1.1), but i have unexpectedly error

> 2019-08-06 22:56:40.131 +05:00 [Warning] Invalid NEST response built from a unsuccessful (400) low level call on POST: /atiruz/\_search?typed\_keys=true
> 
> # Audit trail of this API call:
> 
> - [1] BadResponse: Node: [https://f87fd4280a7944--------cd160f6f03ee54.europe-west1.gcp.cloud.es.io:9243/](https://f87fd4280a7944--------cd160f6f03ee54.europe-west1.gcp.cloud.es.io:9243/) Took: 00:00:00.1334420
> 
> # OriginalException: Elasticsearch.Net.ElasticsearchClientException: Request failed to execute. Call: Status code 400 from: POST /atiruz/\_search?typed\_keys=true. ServerError: Type: search\_phase\_execution\_exception Reason: "all shards failed"
> 
> # Request:
> 
> {"from":0,"query":{"bool":{"filter":[{"geo\_bounding\_box":{"\_name":"Location","boost":1.1,"location":{"bottom\_right":{"lat":41.23020955415123,"lon":69.34550008544922},"top\_left":{"lat":41.368716908561794,"lon":69.13469991455077}}}]},"size":26,"sort":[{"createdDate":{"order":"desc"}}]}
> 
> # Response:
> 
> {"error":{"root\_cause":[{"type":"query\_shard\_exception","reason":"failed to find geo\_point field [location]","index\_uuid":"01aoWJJfSeSLyhgXJX-uIg","index":"atiruz"}],"type":"search\_phase\_execution\_exception","reason":"all shards failed","phase":"query","grouped":true,"failed\_shards":[{"shard":0,"index":"atiruz","node":"RELnlMkQRVWY5BXnJ91ngw","reason":{"type":"query\_shard\_exception","reason":"failed to find geo\_point field [location]","index\_uuid":"01aoWJJfSeSLyhgXJX-uIg","index":"atiruz"}}]},"status":400}

How can i fix this?

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [August 6, 2019, 11:16pm UTC](https://discuss.elastic.co/t/net-core-2-1-elasticsearch-working-in-development-it-doesnt-work-in-release/191503/10 "2019-08-06T23:16:16Z")

</div>

This would be better to open as a New topic, since it's not related to the original topic.

> [@Ilyoskhuja](#):
>
> "failed to find geo\_point field [location]"

It looks like the mapping either does not have a `location` field, or the `location` field is not mapped as a `geo_point`. Check the mapping in the index; if it's incorrect, you'll need to reindex, and if it's not there, you can add it to the index.

---

<div class="post-metadata">

**Author:** ![Ilyoskhuja](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ilyoskhuja/32/47524_2.png) [@Ilyoskhuja](https://discuss.elastic.co/u/Ilyoskhuja)\
**Post date:** [August 7, 2019, 11:19am UTC](https://discuss.elastic.co/t/net-core-2-1-elasticsearch-working-in-development-it-doesnt-work-in-release/191503/11 "2019-08-07T11:19:18Z")

</div>

> [@Cloud elastic account,Reindex docs](https://discuss.elastic.co/t/cloud-elastic-account-reindex-docs/194177):
>
> I use [cloud.elastic.co](http://cloud.elastic.co), my first account working (with reindexing docs and search) , but now I created new account with same version I didnt change reindexing code but i got error 2019-08-06 22:56:40.131 +05:00 [Warning] Invalid NEST response built from a unsuccessful (400) low level call on POST: /atiruz/\_search?typed\_keys=true # Audit trail of this API call: \* [1] BadResponse: Node: https://f87fd4280a7944--------cd160f6f03ee54.europe-west1.gcp.cloud.es.io:9243/ Took: 00:00:…

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 4, 2019, 11:19am UTC](https://discuss.elastic.co/t/net-core-2-1-elasticsearch-working-in-development-it-doesnt-work-in-release/191503/12 "2019-09-04T11:19:19Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
