Summary
composer-dev hardcodes the PostgreSQL host port to 25432, which makes it impossible to run two composer-dev environments concurrently when both use the postgresql database engine.
The resulting error message
Problem
When starting a second environment while another one is already running, composer-dev start fails with:
Port 8090 is already in use. Please use different port or close application using port 8090.
You can select different port by using --port option when starting environment.
This message is misleading. The Airflow web server port (8090 in this example) is not actually in use - the user has already configured distinct port values in each environment's config.json. The real conflict is on port 25432, which both environments' PostgreSQL containers attempt to bind on the host.
Root cause: In composer_local_dev/environment.py, the DB host port is hardcoded:
# environment.py (Environment.database_extras)
"ports": {
f"5432/tcp": "25432",
},
There is no CLI option or config.json field to override it, so every postgresql-backed environment competes for the same host port.
Proposed solution
-
Make the PostgreSQL host port configurable.
- Add an optional
db_port field to config.json (default: 25432, preserving existing behavior).
- Add a matching
--db-port click option to create, start, and restart, mirroring the existing --web-server-port pattern.
- Thread the value through
EnvironmentConfig, Environment.__init__, load_from_config, and from_source_environment, and use it in database_extras in place of the hardcoded "25432".
-
Fix the misleading error message. Inspect the Docker APIError to determine which host port was actually in conflict (web-server vs. DB) and format PORT_IN_USE_ERROR with the correct one. If detection isn't reliable, at minimum mention both candidate ports in the message.
This would unblock running multiple local environments concurrently (e.g. a test and a prod environment side-by-side) and give a clearer signal when a port conflict does occur.
Note: SQLite is file-based, so there's no container port to map, which can be an alternative here.
Summary
composer-devhardcodes the PostgreSQL host port to25432, which makes it impossible to run twocomposer-devenvironments concurrently when both use thepostgresqldatabase engine.The resulting error message
Problem
When starting a second environment while another one is already running,
composer-dev startfails with:This message is misleading. The Airflow web server port (
8090in this example) is not actually in use - the user has already configured distinctportvalues in each environment'sconfig.json. The real conflict is on port25432, which both environments' PostgreSQL containers attempt to bind on the host.Root cause: In
composer_local_dev/environment.py, the DB host port is hardcoded:There is no CLI option or config.json field to override it, so every
postgresql-backed environment competes for the same host port.Proposed solution
Make the PostgreSQL host port configurable.
db_portfield toconfig.json(default:25432, preserving existing behavior).--db-portclick option tocreate,start, andrestart, mirroring the existing--web-server-portpattern.EnvironmentConfig,Environment.__init__,load_from_config, andfrom_source_environment, and use it indatabase_extrasin place of the hardcoded"25432".Fix the misleading error message. Inspect the Docker
APIErrorto determine which host port was actually in conflict (web-server vs. DB) and formatPORT_IN_USE_ERRORwith the correct one. If detection isn't reliable, at minimum mention both candidate ports in the message.This would unblock running multiple local environments concurrently (e.g. a
testand aprodenvironment side-by-side) and give a clearer signal when a port conflict does occur.Note: SQLite is file-based, so there's no container port to map, which can be an alternative here.