COM Add-in error on startup

Our Outlook add-in uses web views to display it’s UI. To make this work, it tries to open a local web-server (accessible from your PC only) under a certain port. If your computer is locked down by your corporate IT, this might fail.

If you check the log files, you’ll see one or more of the following entries:

JiraForOutlook.Lifecycle.AddinLifecycle|Starting web app on "http://localhost:49215/" did not work System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.HttpListenerException: The network location cannot be reached. For information about network troubleshooting, see Windows Help
at System.Net.HttpListener.AddAllPrefixes()
at System.Net.HttpListener.Start()

This error is probably caused by your computer stopping to listen to its own ports and has been solved in the past by running the following command with admin privileges

netsh http add iplisten 127.0.0.1

JiraForOutlook.Lifecycle.AddinLifecycle|Starting web app on "http://localhost:49215/" did not work System.Reflection.TargetInvocationException: Access denied
at System.Net.HttpListener.AddAllPrefixes()
at System.Net.HttpListener.Start()
at Microsoft.Owin.Host.HttpListener.OwinHttpListener.Start(HttpListener listener, Func)

….

This or similar errors might have different reasons:

  • All available local ports are blocked. A simple computer / Windows reboot usually solves this issue.

  • Your Firewall or the VPN is blocking all local ports.

  • Your computer is very restricted by your central IT, in this case, please follow the steps below.


To solve this for restricted PCs, you (or an administrator) will need to run the following commands from an elevated command line. Please make sure to replace “DOMAIN\user” with your actual domain and user name.

netsh http add urlacl url=http://localhost:49215/ user=DOMAIN\user netsh http add urlacl url=http://127.0.0.1:49215/ user=DOMAIN\user

 

Deployment on Citrix / Terminal Server

In case you are facing this error for a deployment on in a virtualized/shared environment, you might need to allow access to more ports, since users share those in some cases. E.g. if user #1 opens Outlook, it will allocate port 49215, so user #2 will not be able to use the same port. Our add-in tries to open a port in the range between 49215-49315. To make this work, you’ll need to allow access to as many ports as you’ll have users on the same machine simultaneously:

netsh http add urlacl url=http://localhost:49215/ user=DOMAIN\userOrGroup netsh http add urlacl url=http://127.0.0.1:49215/ user=DOMAIN\userOrGroup netsh http add urlacl url=http://localhost:49216/ user=DOMAIN\userOrGroup netsh http add urlacl url=http://127.0.0.1:49216/ user=DOMAIN\userOrGroup netsh http add urlacl url=http://localhost:49217/ user=DOMAIN\userOrGroup netsh http add urlacl url=http://127.0.0.1:49217/ user=DOMAIN\userOrGroup ....