I am able to start the emulator but not able to create database. I am using the following code to create a database but it throws an exception
` DocumentClient client = new DocumentClient(
new Uri("https://localhost:8081/"),
"C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==",
new ConnectionPolicy { EnableEndpointDiscovery = false });
try
{
var response = await client.CreateDatabaseAsync(new Database { Id = "application-log" });
Console.WriteLine(response);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
`
The exception message is
{"Service is currently unavailable.\r\nActivityId: 343d2e49-2f31-4fba-bd09-a10cfbe3d13d"}
I am also able to load the emulators data explorer page as shown below

Thanks
I am not sure if port 8081 is working yet. A workaround is to use port 443. Start up your emulator from a command line and type in the following command: documentdb.emulator.exe /port=443. It should work from there.
I tried using port 443. The explorer successfully now opens at
https://localhost/_explorer/index.html but I am still not able to connect to the emulator.
` DocumentClient client = new DocumentClient(new Uri("https://localhost:443/"), "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==",
new ConnectionPolicy { EnableEndpointDiscovery = false });
try
{
var response = await client.CreateDatabaseAsync(new Database { Id = "application-log" });
Console.WriteLine(response);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}`
@hershize This doesn't seems to be a port issue. We had that issue in the very first release of the emulator but it has been fixed now.
@asipras :
You can try couple of things(in the order):
@rnagpal :
Let me know if you need more information. Thanks.
@asipras We are looking into this issue and will update once we are able to root cause this. HttpAddUrlToUrlGroup fails with ERROR_HOST_UNREACHABLE.
I am getting issue with Document DB emulator same as above i have used sample code from Azure site, please find attached file in which i have mentioned all errors, one thing i have also noticed when i click on explorer it doesnt allow me to create databse from portal, where in video Krik has all together diffrent option , is there any dependency or system requirement, i am using windows 10 pro and visual studio 2015 Pro version.
Documentdb.docx
@kiran1472001 I see that you are using port 8080 for the emulator in your code. DocumentDB Emulator by default starts with port 8081. I'm assuming that you launched the emulator with /port=8080.
We are aware of the Data Explorer issue(local portal like interface) which removed most of the operations as shown in the video and we are working on a fix to restore them back.
Please follow the steps I mentioned above and send us the generated docdbemulator_000001.etl so that we can investigate the reason for the Service Unavailable error you are seeing as there can be different causes for that.
Hello,
same problem here with the sample app and my custom app (which works fine on Azure). No firewall\hybernation.
@rnagpal Thanks for letting me know.
I'm observing the same issue. I don't know, but maybe it has something to do with the network binding: the emulator is listening on 127.0.0.1:8081 only, but localhost is resolved to ::1, if the system prefers ipv6 over ipv4. Unfortunatley, you can't change the endpoint-url to 127.0.0.1:8081, because this leads to an http 403 with "Database Account 127 does not exist".
In order to eliminate a cause with regard to the locale, I've changed my locale to en-us and reinstalled the emulator. But this doesn't resolve the problem.
@kontax85 @chkpnt Can you please refer to the Troubleshooting guidelines at the end of https://docs.microsoft.com/en-us/azure/documentdb/documentdb-nosql-local-emulator and send us the trace file so that we can look into it.
@kiran1472001 Can you respond to my comment?
@asipras Just checking if you were able to resolve this or else we will look into it.
@chkpnt, can you please send us an email at [email protected]. We'd like to get some additional details to debug this,
@rnagpal I was not able to resolve this issue. I had to test my code on my personal msdn Azure subscription. Please guide us so we can use the emulator during software development.
@asipras Can you please refer to the Troubleshooting guidelines at the end of https://docs.microsoft.com/en-us/azure/documentdb/documentdb-nosql-local-emulator and send us the latest trace file so that we can look into it? Email us as [email protected] by attaching the trace file.
@rnagpal I have emailed the trace file with subject: GitHub Issue #185.
Thanks.
@asipras @chkpnt We are investigating the issue and will let you know once we have an update.
Momin has noted the following based on my trace file:
The emulator is failing with WSAEADDRNOTAVAIL when trying to listen on 192.168.137.1.
I've seen in the resource monitor, that DocumentDB.GatewayService.exe is indeed trying to connect to 192.168.137.1, which doesn't exist in my network. Further non of my NICs has this ip configured. But one of my wired NICs, which isn't currently in use, had "Internet Connection Sharing" enabled. And after I had disabled internet-sharing and restarted the emulator, I was able to use the emulator as intended. š
To my mind, the emulator shouldn't depend on the internet-sharing-property, so this sounds like a bug.
In the meantime, disabling internet-sharing may help other users as well.
Additionally, to my mind, the emulator should listen on ::1 as well.
I've enabled to prefere IPv4 over IPv6 using this easy fix wizard some days ago; I don't know, if disabling the internet-sharing would have been sufficient in my case.
@asipras I see that you are working with Momin on this. Let me know if this issue is resolved so that I can close this issue.
@kontax85 @kiran1472001 : Any updates based on my comments above for your cases? Please email [email protected] if you still need help.
Yes Momin gave me a link to download a new setup which has the fix. I installed the emulator using the new setup and everything worked !!! The new build with the fix is not out yet, Momin said the fix will be made public in coming weeks.
You can close this issue for now. Thanks for your help.
I'll close this issue now. If anyone runs into this issue, please email [email protected] with traces attached as outlined in https://docs.microsoft.com/en-us/azure/documentdb/documentdb-nosql-local-emulator#troubleshooting
I'm also having difficulty connecting to the emulator via both the .Net and .Net core sample apps, as well as creating a db/collection via the the explorer prompt to do so. Let me know if you still need trace files. And also I am interested in when the possibly fixed version to this will be available?
@jonathanfishbein1 Please open a new issue as each issue in emulator is a different one specific to your environment. Preferably, send an email to [email protected] with the traces and we can follow up from there.
I am seeing this issue as well, using the following launch parameters:
./DocumentDB.Emulator.exe /DataPath=E:\DocDB01 /Port=8081 /AllowNetworkAccess /KeyFile=E:\DocDB01\keyfile
In Postman, using x-ms-version and Authorization headers:
{
"code": "InternalServerError",
"message": "Service is currently unavailable, please retry after a while. If this problem persists please contact support.\r\nActivityId: 7e21e1ac-2a18-4e19-867e-489efd44ad24"
}
I am using the DocumentDB.emulator and I have encountered the same problem. My system is windows 8.1 and I use the vs2015. I also see in the official website that the system requirement is windows10 or windows server 2012. So I am wondering if the proplem is due to my system.
@jonathanfishbein1 Did you sent the traces to [email protected]? If the issue still presenty, please send email as we need to look into the traces.
@darkshade9 Can you please email [email protected] with traces attached as outlined in https://docs.microsoft.com/en-us/azure/documentdb/documentdb-nosql-local-emulator#troubleshooting to debug this further?
@Eric-mingjie As I responded in your new issue you created for the same, you need Windows 10 and above to work with emulator.
@rnagpal Trace file sent to [email protected]
Thanks
I worked with Momin at Microsoft and did some troubleshooting, I think the issue I ran into was involving the /DataPath parameter; if I remove it, the emulator runs as expected, even over the network.
The emulator did not error or log any problems with this setting, so it would be nice to have a little more chattiness with errors.
@rnagpal Thanks a lot. I have already solved the problem.
@rnagpal I have the same Issue.. I wrote an email to [email protected], could you please check? Thanks
I had what I thought was the same issue but it turned out to be #194 - there is an issue with using Direct mode at the moment. Switching to Gateway (which is the default) for now resolves the issue for me.
I was using Direct due to the performance tips provided here.
+1 for @nftw 's point. I've just hit this issue - the emulator does not work when the Client connection mode is set to "Direct"
I am unable to start the emulator all together. I get a message that it shuts down immediatly after it starts. Tried everything suggested here. At
docdbemulator_000001.zip
tached trace.
I had the same issue -- I don't think my computer ever hibernated, but maybe? -- Anyway, I right clicked and hit "Reset Data", at which point it told me it would need to restart to do that, so I let it restart. -- And my local emulator appears to be working again now. -- At least on one machine. XD
I keep on receiving a "Service Unavailable" message even though I stopped applications that use port 8081 and started the emulator in that port.
I also tried setting preference over IPv4, reseting data, openning firewall rules and every answer I found in this blog. By the way the 443 port config have a strange behavior making the buttons of the explorer tab dissapear.
I'm using windows 10, and the emulator is installed with MSI.
I'll attach the traces file in an email to [email protected]
+1 for @nftw answer. The emulator simply does not work locally with Direct ConnectionMode. Seems like a bug.
I frequently travel on long-haul flights without a net connection and am unable to start Cosmos DB emulator on those occasions. Is there a workaround to requiring a net connection???
@projecteon did you ever resolve this issue? I am encountering the same problem right now on my dev machine.
@FredrikGoransson No, I did not. I think I ended up with uninstalling and reinstalling several times (perhaps with reboots inbetween) and suddenly it had solved itself. I had lost all previous data however.
Not sure what happened. The emulator on my machine suddenly could not be accessed by code. It kept returning "service unavailable" exception. I installed Docker for Windows on this machine today. Not sure if it is related to the problem.
"Reset data" option helped to resolve the problem. Now I have to reload all data into the emulator again.
@chunliu
Yes this worked for me as well. Thanks for the comment!! I'd been pulling what's left of my hair out. Installed docker as well. Reset data worked for me.
I had the "Service Unavailable" issue with Azure Cosmos DB Emulator. It was caused by a Mcafee firewall. If you turn it off and use Windows Firewall, when launching the emulator it will ask about rules to put into the Windows Firewall which will allow the emulator to work. I can now use the Data explorer Web UI to create collections etc. š
Encountered the Service Unavailable issue today (been working fine for long).
Using the "Reset data..." option did the trick for me.
I am still having these issues. When I try to set the port I have to set many other parameters. Is there any solution or is this a known issue that needs to be circumvented? I do not have CosmosDB Emulator as a running process to Reset Data. Yet it still exists at port 8081. looking into console I found http://localhost:8081/ Content Security Policy: The pageās settings blocked the loading of a resource at self (ādefault-srcā). Currently debugging this.
The emulator was in a bad state. My solution was to find and kill the process with :
https://stackoverflow.com/questions/39632667/how-to-kill-a-currently-using-port-on-localhost-in-windows?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
To fix this I had to perform a "Reset Data" on the Emulator. This is probably due to some issue around updating from DocumentDb to Cosmo Db emulator.
I was finally able to get V2 of the emulator working by following this:
I noticed the errors in VS during debugging that "Unknown Server Error Had Occurred" on the DocumentDB dll. After a bit of trial and error, I found the answers in a mix of blogs. This is what I finally did to fix the issue.
Hmmm, My issue may be related.
I can start the emulator (v2) and it serves https://localhost:8081/_explorer/index.html successfully. However, when I attempt to go to Explorer, it just sits there forever.
When I attempt to run a unit test to create a Database on the emulator:
await client.CreateDatabaseAsync(new Database { Id = databaseId });
It will timeout, this is with having the DocumentClient (NET Core - Microsoft.Azure.DocumentDB.Core) configured to connect to the endpoint defined in the explorer: https://localhost:8081
Since my unit test times out and the Emulator UI at https://localhost:8081/_explorer/index.html also effectively times out (when accessng the Data Explorer) I'm at a loss where to look next.
i agree Reset Data works but its not a solution i can rely on as we sync lot of data to local DB and reset data puts me back to square one , any other solution is really appreciated.
I am facing the same issue even in version 2.4.3.0. I had to reset data to fix it.
Most helpful comment
I had what I thought was the same issue but it turned out to be #194 - there is an issue with using
Directmode at the moment. Switching toGateway(which is the default) for now resolves the issue for me.I was using
Directdue to the performance tips provided here.