Running SonarQube Locally When Port 9000 Is Already in Use
Get your code quality analysis running on any port you choose
📅 October 29, 2025 | ⏱️ 5 min read | 🏷️ Docker, SonarQube, DevOps
So you've got SonarQube set up on your machine, but port 9000 is already occupied by another service? Don't worry—this is a pretty common issue, especially when you're juggling multiple development tools.
The good news is that Docker makes it incredibly easy to run SonarQube on a different port. You just need to understand how port mapping works.
The Solution
Here's the command that'll get you up and running:
docker run -itd --name SonarQube-Server-2 -p 9000:9000 sonarqube:lts-community
But wait—if port 9000 is already taken, you'll want to modify this. Here's where it gets interesting.
Understanding Port Mapping
The -p flag in Docker follows this pattern: -p HOST_PORT:CONTAINER_PORT
The first number is the port on your local machine (host), and the second is the port inside the container. SonarQube always runs on port 9000 inside the container, but you can map it to any available port on your machine.
Running on a Different Port
Let's say you want to access SonarQube through port 8080 instead. Simply change the first number:
docker run -itd --name SonarQube-Server-2 -p 8080:9000 sonarqube:lts-community
Now you can access SonarQube by visiting http://localhost:8080 in your browser. You could use port 9001, 9090, or literally any available port—just replace that first number.
Quick Tip
Before running the command, you can check which ports are already in use on your system. This saves you from trial and error when picking a port number.
The beauty of Docker is that you can run multiple instances of SonarQube simultaneously, each on a different port, if you ever need to test different configurations or versions.
Pro Tip: You can check which ports are in use on your system with netstat -tuln on Linux or netstat -ano on Windows.
Comments
Post a Comment