Challenge, Medium,  on  LinuxNetworking

Resolve a Port Conflict and Keep All Dev Services Running

You're working in a remote development environment with two applications checked out under ~/projects:

  • storefront - a small e-commerce app, organized as a monorepo with a Node.js web UI (frontend/) and a Go catalog API (backend/).
  • orders-api - a standalone Go API service.

Neither app is running yet. Each service has a small Makefile - run make start inside its directory to build and run it.

Your tasks

1. Start the storefront. Bring up both of its parts so the web UI works on port 3000. Open the Storefront (Web UI) tab - you should see the product catalog.

2. Start the orders-api on port 4000 - while keeping the storefront fully functional. Its web UI must stay reachable on the original port and keep showing the catalog.

Refresh the Storefront (Web UI) tab at any point to check whether the storefront still works.

Hint 1

Begin with the storefront. It's a monorepo with two parts - backend/ and frontend/ - each with its own Makefile. Start each one with make start in its directory (one terminal per part). Once both are up, the web UI on port 3000 will show the catalog.

Hint 2

The orders-api needs port 4000, but if you try to start it, you will see an error saying that the port is already in use. Only one process can listen on a TCP port at a time - find out what's already there and find a way to resolve the conflict.

Hint 3

Port 4000 is held by the storefront's catalog backend - and you can't simply stop the storefront to free it, because the storefront has to keep working. The way out is to relocate the catalog backend to a different, free port, while keeping the web UI on 3000. Find where the backend's port is configured, change it to some other value and restart the backend to apply the changes.

Hint 4

If, after moving the backend, the web UI starts showing a "catalog unavailable" page, the frontend is still trying to reach the backend at its old address. Find where the frontend's backend address is configured, then update it to the backend's new port and restart the frontend.