Cannot access asp net core app when run with docker on local machine or to kub


ASP.NET is a popular programming used for building web applications. It provides a framework for developing dynamic , web services, and web APIs. However, sometimes developers may encounter issues when trying to access an ASP.NET Core app when running it with Docker on a machine or Kubernetes (kub) cluster. In this article, we will explore some possible solutions to this problem.

Understanding the Issue

When running an ASP.NET Core app with Docker or Kubernetes, the app may not be accessible from the local machine or the kub cluster. This can be due to various reasons, such as incorrect network configurations, firewall settings, or networking issues.

Solution 1: Check Network Configurations

The first step is to ensure that the network configurations are set up correctly. In Docker, make sure that the app's container is running on the host network or has the necessary port mappings. For example, if the app is on port 5000, you can map it to the host machine's port 5000 using the following command:

docker run -p 5000:5000 myapp

In Kubernetes, check the service and ingress configurations to ensure that the app's ports are exposed correctly. For example, you can define a service and ingress rule to expose the app on port 80:

apiVersion: v1
kind: Service
  name: myapp-service
    app: myapp
    - protocol: TCP
      port: 80
      targetPort: 5000


kind: Ingress
  name: myapp-ingress
    - host:
          - path: /
            pathType: Prefix
                name: myapp-service
                  : 80

Solution 2: Check Firewall Settings

If the network configurations are correct, the issue may be related to firewall settings. Ensure that the necessary ports are open in the firewall to allow incoming to the ASP.NET Core app. For example, if the app is listening on port 5000, you can open the port using the following command:

sudo ufw allow 5000

Make sure to adjust the command based on your firewall configuration.

Solution 3: Check Container Networking

If the app is running a container, may be container networking issues. Ensure that the container is connected to the correct network and that the necessary ports are exposed. For example, you can use the following Docker command to run the container on the host network:

docker run --network host myapp

Alternatively, you can create a Docker network and connect the container to it:

docker network create mynetwork
docker run --network mynetwork myapp


When encountering issues an ASP.NET Core app running with Docker or Kubernetes, it is important to check the network configurations, firewall settings, and container networking. By following the solutions provided in this article, you should be able to resolve the problem and access your ASP.NET Core app successfully.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents