CosmosDB emulator can't start since port is already in use

Viewed 10994

I'm giving CosmosDB a chance and so I decided to build an app that uses it, but I'm running into this issue when using the emulator: Port is already in use.

I'm not sure where to reconfigure the port the emulator is pointing.

enter image description here

7 Answers

If you prefer just to change the Windows Shortcut, right click > properties and add /port=8082 (or whatever port number you want) at the end of the Target field after the quotes.

Note that in the Emulator Data Explorer, the URI field still showed the default port of 8081.

Shortcut properties

The CosmosDbEmulator comes with a PowerShell module, which you can use to control it.

To get started using the module run the following command:

 Import-Module "$env:ProgramFiles\Azure Cosmos DB Emulator\PSModules\Microsoft.Azure.CosmosDB.Emulator"

Start the CosmosDbEmulator on a port of your choice, e.g 8082 as follows:

Start-CosmosDbEmulator -port 8082

I finally got it working with powershell.

Import module

$env:PSModulesPath += "$env:ProgramFiles\Azure Cosmos DB Emulator\PSModules"
Import-Module Microsoft.Azure.CosmosDB.Emulator

Stop CosmosDB emulator

Stop-CosmosDbEmulator

Start CosmosDB emulator with prefered port

Start-CosmosDbEmulator  -Port 10101

And I got it working... Hope this helps.

Check your processes list and find one like Microsoft.Azure.Cosmos.GatewayService.exe. Kill it. Then I can start Cosmos emulator.

With the latest (2.14.3) that I installed today, you need to specify /mongoport instead of /port.

enter image description here

Related