.net core docker centos HttpRequest error: (Socket Exception) Resource temporarily unavailable

Viewed 8395

I have spent a lot of time and tried everything that I could find on Google but could not make it work.

  1. I have a working docker container with a .Net Core app 3.1 Blazer.
  2. I have hosted this on a Linux server centOS 8. It looks like a clear docker container without Kubernetes, etc...
  3. I can open my web site and use it

But I can't send requests from my app, something like the following:

var response = await (await httpClient.GetAsync($"requestString}")).Content.ReadAsStringAsync();  

At this part of code i have error:

Unhandled exception rendering component: Resource temporarily unavailable System.Net.Http.HttpRequestException: Resource temporarily unavailable ---> System.Net.Sockets.SocketException (11): Resource temporarily unavailable at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken) --- End of inner exception stack trace ---

4 Answers

Turn off firewalld, then restart docker.

sudo systemctl stop firewalld
sudo systemctl disable firewalld

I had a similar problem with a netcore app which could not access a custom hosts entry.

Kudos to @gekctek for pointing me in the right direction, I found that my docker container could access the internet, but that the container could not access a custom entry in my host's /etc/hosts file

To get around this, I added a volume mapping in the docker-compose file so that the container's /etc/hosts entry would match that of the host, and it worked

enter image description here

After rotating your cluster certificates you may see a persistent error with pods crashlooping with this error.

Scale down to 0 nodes and scale up again to resolve this.

Had the same error with Docker Swarm - tried disabling firewalld as per above but in the end, for my .NET container I had forgotten to add access to the external network so it could hit the internet - it only had access to the internal network. The ultimate firewall..

Related