Skip to content
DevOps AI ToolKit
Newsletter
All guides
AI for Loki By James Joyner IV · · 8 min read

Loki Error Guide: 'bind: address already in use' — Free the Port or Change the Listener

Quick answer

Fix Loki 'listen tcp :3100: bind: address already in use': free the port, change http_listen_port or grpc_listen_port, and avoid collisions.

  • #loki
  • #logging
  • #troubleshooting
  • #errors
Free toolkit

Fixing errors like this? Get 500 free DevOps AI prompts

500 copy-paste AI prompts for the stack you actually run — one PDF, free.

Overview

Loki cannot start when the TCP port it wants to listen on is already held by another process. The Go net stack reports the bind failure and Loki exits immediately:

error running loki: ... listen tcp :3100: bind: address already in use

The same failure appears for Loki’s other listeners — the gRPC port and the memberlist gossip port:

listen tcp :9095: bind: address already in use
listen tcp :7946: bind: address already in use

Loki opens an HTTP listener (http_listen_port, default 3100), a gRPC listener (grpc_listen_port, default 9095), and, in a distributed deployment, a memberlist port (7946). If anything already owns one of those addresses — an old Loki instance that did not fully terminate, a second Loki component configured on the same port, or an unrelated process — the bind fails. The fix is to free the port or move Loki’s listener, never to leave two things fighting over the same address.

Symptoms

  • Loki exits at startup with bind: address already in use naming a specific port.
  • A previous Loki process is still running (or shutting down) and holding the address.
  • Two Loki targets (e.g. two single-binary instances, or a component duplicated) are configured on the same http_listen_port.
  • The error clears after a short wait, indicating a slow graceful shutdown of the prior instance.
  • With hostNetwork: true, a node-local port collision surfaces even though each pod looks isolated.

Common Root Causes

  • Old instance still bound — a previous Loki process did not fully terminate and still holds 3100/9095, so the new one cannot bind.
  • Two components on the same port — two Loki targets or replicas configured with the same http_listen_port or grpc_listen_port on one host.
  • Sidecar or unrelated process collision — another container or process on the node already listens on the port Loki wants.
  • Slow or blocked graceful shutdown — the prior instance is draining and has not released the socket yet.
  • hostNetwork port clash — running with host networking removes pod-level isolation, so any node-local user of the port conflicts.

How to diagnose

  1. Confirm the config is otherwise valid so you know the failure is purely the bind, not a bad listener setting:

    loki -config.file=/etc/loki/config.yaml -verify-config
  2. Read the logs to capture exactly which port failed to bind:

    kubectl logs -l app=loki --tail=20 | grep 'address already in use'
  3. Check which ports Loki is configured to open so you know what must be free:

    server:
      http_listen_port: 3100
      grpc_listen_port: 9095
    memberlist:
      bind_port: 7946
  4. Find the process holding the port on the host or in the pod’s network namespace:

    ss -ltnp | grep -E ':3100|:9095|:7946'
  5. Confirm no duplicate Loki is running before restarting, so you are not racing a still-live instance:

    lsof -iTCP:3100 -sTCP:LISTEN

Fixes

Find and stop the process holding the port. Identify the PID with ss/lsof, then terminate the stale holder so the address is released:

# identify the listener, then stop it
PID=$(ss -ltnp 'sport = :3100' | grep -oP 'pid=\K[0-9]+' | head -1)
[ -n "$PID" ] && kill "$PID"

Change the Loki listener when the port legitimately belongs to something else — move the HTTP or gRPC port rather than fighting for it:

server:
  http_listen_port: 3200
  grpc_listen_port: 9195

Ensure only one process per port by giving each Loki component or replica its own listener, so two targets never claim the same address on one host:

# component B on a distinct port range
server:
  http_listen_port: 3101
  grpc_listen_port: 9096

Wait for graceful shutdown to complete before restarting, so the previous instance releases the socket. Give the pod a realistic termination grace period:

spec:
  terminationGracePeriodSeconds: 60

Avoid hostNetwork port collisions by dropping host networking, or by ensuring the node-local ports are unique when you must keep it:

spec:
  hostNetwork: false   # let each pod have its own network namespace

What to watch out for

  • Restarting Loki before the old instance finishes draining just reproduces the error; confirm the prior process is gone with ss/lsof first.
  • 3100 (HTTP), 9095 (gRPC), and 7946 (memberlist) are all separate listeners — read the message to see which one collided.
  • Changing a port means updating every client, probe, and datasource that targeted the old one, or you trade a bind error for a connection-refused error.
  • With hostNetwork: true you lose pod isolation, so two Loki pods scheduled on the same node will always collide on identical ports.
  • A liveness probe that kills a slow-starting Loki can leave a half-bound socket; align the probe’s initialDelaySeconds with real startup time.
Free download · 368-page PDF

Get 500 Battle-Tested DevOps AI Prompts — Free

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.