<p>I have been trying to get my kubernetes to launch my web application on a browser through my local host. When I try to open local host it times out and I have tried using minikube service --url  and that also does not work. All of my deployment, and service pods are running. I have also tried port forward and changing the type to nodeport.  I have provided my <a href="https://i.stack.imgur.com/FqbHp.png" rel="nofollow noreferrer">yaml</a>, <a href="https://i.stack.imgur.com/s5ydJ.png" rel="nofollow noreferrer">docker</a>, and <a href="https://i.stack.imgur.com/oM4MA.png" rel="nofollow noreferrer">svc code</a>.</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: mywebsite
spec:
  type: LoadBalancer
  selector:
    app: mywebsite
  ports:
  - protocol: TCP
    name: http
    port: 8743
    targetPort: 5000


---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mywebsite
spec:
  selector:
    matchLabels:
      app: mywebsite
  template:
    metadata:
      labels:
        app: mywebsite
    spec:
      containers:
      - name: mywebsite
        image: mywebsite
        imagePullPolicy: Never
        ports:
        - containerPort: 5000
        resources:
          requests:
            cpu: 100m
            memory: 250Mi
          limits:
            memory: &quot;2Gi&quot;
            cpu: &quot;500m&quot;   
</code></pre>
<pre><code># For more information, please refer to https://aka.ms/vscode-docker—python
FROM python:3.8-slim-buster

EXPOSE 8000
# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1

# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1

# Install pip requirements
COPY requirements.txt .
RUN python -m pip install -r requirements.txt

WORKDIR lapp
COPY . .

# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# For more info, please refer to https://aka.ms/vscode—docker-python—configure-containers
RUN adduser -u 5678 --disab1ed-password --gecos &quot;&quot; appuser &amp;&amp; chown -R appuser /app
USER appuser

CMD [&quot;python&quot;, &quot;manage.py&quot;, &quot;runserver&quot;, &quot;0.0.0.0:8000&quot;]
</code></pre>
<pre><code>Name:                     mywebsite
Namespace:                default
Labels:                   &lt;none&gt;
Annotations:              &lt;none&gt;
Selector:                 app=mywebsite
Type:                     LoadBalancer
IP Family Policy:         SingleStack
IP Families:              IPv4
IP:                       10.99.161.241
IPs:                      10.99.161.241
Port:                     http 8743/TCP
TargetPort:               5000/TCP
NodePort:                 http 32697/TCP
Endpoints:                172.17.0.3:5000
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   &lt;none&gt;
</code></pre>

Julian Romero
<p>it's due to your container running on port <strong>8000</strong></p>
<p>But your service is forwarding the traffic to <strong>5000</strong></p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: mywebsite
spec:
  type: LoadBalancer
  selector:
    app: mywebsite
  ports:
  - protocol: TCP
    name: http
    port: 8743
    targetPort: **8000**
</code></pre>
<p>deployment should be</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: mywebsite
spec:
  selector:
    matchLabels:
      app: mywebsite
  template:
    metadata:
      labels:
        app: mywebsite
    spec:
      containers:
      - name: mywebsite
        image: mywebsite
        imagePullPolicy: Never
        ports:
        - containerPort: **8000**
        resources:
          requests:
            cpu: 100m
            memory: 250Mi
          limits:
            memory: &quot;2Gi&quot;
            cpu: &quot;500m&quot;
</code></pre>
<p>You need to change the <strong>targetPort</strong> in <strong>SVC</strong></p>
<p>and <strong>containerPort</strong> in <strong>Deployment</strong></p>
<p><strong>Or else</strong></p>
<p>change the</p>
<p><code>EXPOSE 8000</code> to <strong>5000</strong> and command to run the application on <strong>5000</strong></p>
<pre><code>CMD [&quot;python&quot;, &quot;manage.py&quot;, &quot;runserver&quot;, &quot;0.0.0.0:5000&quot;]
</code></pre>
<p>Dont forget to docker build one more time after the above changes.</p>
