# Unable to connection elastic cloud into online website but working fine into local system

**URL:** <https://discuss.elastic.co/t/unable-to-connection-elastic-cloud-into-online-website-but-working-fine-into-local-system/149423>\
**Category:** Elasticsearch\
**Created:** [September 21, 2018, 9:35am UTC](https://discuss.elastic.co/t/unable-to-connection-elastic-cloud-into-online-website-but-working-fine-into-local-system/149423 "2018-09-21T09:35:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sangeetshah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sangeetshah/32/35794_2.png) [@sangeetshah](https://discuss.elastic.co/u/sangeetshah)\
**Post date:** [September 21, 2018, 9:35am UTC](https://discuss.elastic.co/t/unable-to-connection-elastic-cloud-into-online-website-but-working-fine-into-local-system/149423/1 "2018-09-21T09:35:08Z")

</div>

i have login into elastic cloud and get the cloud url and password to connect this account from c# language and able to index and search my index data from cloud elastic.

I have created application into .net core c# and working fine into local pc with indexing,searching and etc action but this not working into my website. it give me error as below mention:-

```
Short message	
One or more errors occurred. (An attempt was made to access a socket in a way forbidden by its access permissions)
Full message	
System.AggregateException: One or more errors occurred. (An attempt was made to access a socket in a way forbidden by its access permissions) ---> 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 Nop.Web.Areas.Admin.Custom.Service.ElasticSearchService.SuggestedProductAsync(String keyword, Int32 pageIndex, Int32 pageSize)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at Nop.Web.Factories.CatalogModelFactory.PrepareElasticSearchModel(SearchModel model, CatalogPagingFilteringModel command)
   at Nop.Web.CustomCode.Controllers.ElasticSearchController.Search(SearchModel model, CatalogPagingFilteringModel command)
   at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
   at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
   at StackExchange.Profiling.MiniProfilerMiddleware.Invoke(HttpContext context) in C:\projects\dotnet\src\MiniProfiler.AspNetCore\MiniProfilerMiddleware.cs:line 86
   at Nop.Services.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) in D:\Sangeet Shah\Project\ElasticSearch\Libraries\Nop.Services\Authentication\AuthenticationMiddleware.cs:line 79
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Nop.Core.Http.InstallUrlMiddleware.Invoke(HttpContext context, IWebHelper webHelper) in D:\Sangeet Shah\Project\ElasticSearch\Libraries\Nop.Core\Http\InstallUrlMiddleware.cs:line 51
   at Nop.Core.Http.KeepAliveMiddleware.Invoke(HttpContext context, IWebHelper webHelper) in D:\Sangeet Shah\Project\ElasticSearch\Libraries\Nop.Core\Http\KeepAliveMiddleware.cs:line 50
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context)
---> (Inner Exception #0) 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 Nop.Web.Areas.Admin.Custom.Service.ElasticSearchService.SuggestedProductAsync(String keyword, Int32 pageIndex, Int32 pageSize)<-

```

my code look like this :-  
var settings = new ConnectionSettings(new Uri("[http://username:password@elasticurl](http://username:password@elasticurl)"))  
.DefaultIndex("people");

```
            var client = new ElasticClient(settings);
            var person = new Person
            {
                Id = 1,
                FirstName = "Martijn",
                LastName = "Laarman"
            };
            var indexResponse = client.IndexDocument(person);
            var asyncIndexResponse = client.IndexDocumentAsync(person);

```

for searching code  
ISearchResponse searchResponse = elasticClient.SearchAsync(s =\> s  
//.Index(indexName)  
.Suggest(su =\> su  
.Completion("suggestions", c =\> c  
.Field(f =\> f.Suggest)  
.Prefix(keyword)  
.Fuzzy(f =\> f  
.Fuzziness(Fuzziness.Auto)  
))).Skip(skipno).Take(pageSize));

```
            if (searchResponse.Suggest == null || !searchResponse.Suggest.Any())
                return null;

            var query = from suggest in searchResponse.Suggest["suggestions"]
                        from option in suggest.Options
                        select option.Source;
```

---

<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:** [October 19, 2018, 9:35am UTC](https://discuss.elastic.co/t/unable-to-connection-elastic-cloud-into-online-website-but-working-fine-into-local-system/149423/2 "2018-10-19T09:35:10Z")

</div>

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