Port Mapping and Conflict Resolution
Who this is for
Users who need to understand how ports work in CloudAIPilot, how to avoid port conflicts, and how to resolve them.
What Is Port Mapping?
Port mapping connects a host port (on the server's network) to a container port (inside the Docker container). For example:
- Host port
8080→ Container port3000 - A request to
http://server-ip:8080is forwarded to port3000inside the container.
This is identical to Docker's -p 8080:3000 flag.
How to Choose Ports
| Port range | Recommendation |
|---|---|
| 1–1023 | System ports — avoid (requires root) |
| 1024–8079 | Available — prefer this range |
| 8080–8099 | Common web app ports |
| 3000, 4000, 5000 | Common dev ports — fine for production |
| 9000–9999 | Common admin/metric ports |
Avoid using ports already reserved for:
80— Nginx HTTP443— Nginx HTTPS22— SSH3306— MySQL5432— PostgreSQL6379— Redis
Port Conflict Detection
Before creating or updating an app, you can check for conflicts:
Via the UI:
- In the Create App form, if you enter a port that is already in use, a warning badge appears.
- The warning shows which app or site is using the port.
Via the port check endpoint:
- CloudAIPilot checks port availability before finalizing any app creation.
- If a conflict exists, it returns: which resource (app/site), its name, and its ID.
What Happens If You Try to Use a Conflicting Port
CloudAIPilot returns a PORT_CONFLICT error at create or update time. The app is not created. Choose a different host port.
For cloned apps, CloudAIPilot automatically bumps the port to the next available one if the original port is in use.
Compose App Port Mapping
For compose apps, port mappings are tracked per service:
- Each service in the
docker-compose.ymlthat exposes a host port must be listed in the Port Mappings section. - This allows CloudAIPilot to track which ports are in use and detect conflicts across apps and sites.
Viewing Registered Ports for an App
- Open the app detail.
- The Overview shows the registered port mappings.
- Or check the Ports section in the app detail page.
Cleaning Up Ports After App Deletion
When an app is deleted, CloudAIPilot:
- Stops the container and removes it.
- Closes the UFW firewall rule for the host port.
- Closes the cloud provider's firewall rule if one was opened.
- Soft-deletes the AppPort rows, releasing the port for future use.
What Success Looks Like
The app runs with the configured ports. No conflict errors. Accessing http://server-ip: reaches the container.
Common Issues and Fixes
| Issue | Likely cause | Fix |
|---|---|---|
| "PORT_CONFLICT" on create | Port already in use by another app or site | Use the port check tool to see what's using the port. Choose a different port. |
| App running but port not accessible | Server firewall blocking the port | Add the port to the firewall in the server's Firewall tab. |
| Compose port not tracked | Port defined in compose YAML but not in port mapping section | Add the port to the port mapping list in the Create App form. |