# .NET Core elastic not working in server

**URL:** <https://discuss.elastic.co/t/net-core-elastic-not-working-in-server/196443>\
**Category:** Elasticsearch\
**Created:** [August 23, 2019, 5:12am UTC](https://discuss.elastic.co/t/net-core-elastic-not-working-in-server/196443 "2019-08-23T05:12:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DotNetLoper](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dotnetloper/32/52870_2.png) [@DotNetLoper](https://discuss.elastic.co/u/DotNetLoper)\
**Post date:** [August 23, 2019, 5:12am UTC](https://discuss.elastic.co/t/net-core-elastic-not-working-in-server/196443/1 "2019-08-23T05:12:02Z")

</div>

I have tested ElasticSearch in my localhost, it is working fine. But when I deployed to hosting server, it is not working. I use [asphostportal.com](http://asphostportal.com). This is my code:

```
            {public static class ElasticsearchExtensions
{
    public static void AddElasticsearch(
        this IServiceCollection services, IConfiguration configuration)
    {
        var defaultIndex ="hedonasp";
       
   
        var settings = new ConnectionSettings(new Uri("https://711e0c87a+++++++=========dc2528152891.us-east-1.aws.found.io:7895"))
            .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("hedonasp", c => c
                      .Mappings(m => m.Map<ElasticSearchModel>(mm => mm
                     .AutoMap()
                        ))
                        .RequestConfiguration(r => r
                        .DisableDirectStreaming()
)
              );

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

```

}

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 23, 2019, 7:12am UTC](https://discuss.elastic.co/t/net-core-elastic-not-working-in-server/196443/2 "2019-08-23T07:12:20Z")

</div>

Hey,

can you provide responses with error codes or exceptions to be able to see what is happening?

---

<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 20, 2019, 7:12am UTC](https://discuss.elastic.co/t/net-core-elastic-not-working-in-server/196443/3 "2019-09-20T07:12:25Z")

</div>

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