Search code examples
c++httplocalhostwinhttp

HttpAddUrl on localhost fails for non-admin users


Using the Windows HTTP API I'm running a HTTP file server on localhost.

This involves calling HttpAddUrl(hRequestQueue, L"http://localhost:80/", NULL).

This fails with ERROR_ACCESS_DENIED unless the user runs the application as administrator. I need this functionality for users who don't have admin privileges. (What's wrong with a user running a localhost server anyway? It's just for the user themselves.)

I found a hotfix for Vista and XP which seems aimed at solving this, but there's nothing for Windows 7. The article implies it was fixed in Vista SP1, and I have Windows 7 SP1 and it's still a problem - did the fix not make it to Windows 7?

Is there anything else I can do to get the server to run for non-admins?


Solution

  • Answering my own question, but found a workaround: the IANA port numbers state ports 49152-65535 are for dynamic/private purposes. HttpAddUrl for localhost on a port >= 49152 works fine for non-admins.