Error 401 When Accessing Port-Forwarded NI Web Servers

Updated Mar 17, 2025

Issue Details

I have used my network router to port forward multiple NI Web Servers hosted on different machines. Whenever I try to access multiple NI Web Servers using a single browser through the port-forwarded address, I get the following error. How to resolve this issue?

Error 401 - Unauthorized

error image

Solution

This issue is caused by the clashing of session cookies of multiple NI Web Servers in a single browser. Perform the following on each of the machines hosting the NI Web Server to resolve this issue:

  1. Create C:\Program Files\National Instruments\Shared\Web Server\conf\conf.d\51_session_cookie.conf
  2. Open 51_session_cookie.conf with a text editor application.
  3. Insert the following content:
    <Location />
        <IfDefine TLS_ENABLED>
            SessionDBDCookieName <cookie_name>_secure path=/;HttpOnly;Secure;SameSite=Lax
        </IfDefine>
        <IfDefine !TLS_ENABLED>
            SessionDBDCookieName <cookie_name> path=/;HttpOnly;SameSite=Lax
        </IfDefine>
    </Location>
  4. Replace the <cookie_name> with a unique name as the name of the session cookie.
  5. Restart NI Web Server.

Additional Information

When logging into NI Web Server, session cookies will be created. This session cookies are scoped per hostname or IP address, not per port. Therefore, when someone port-forwarded multiple NI Web Servers and attempts to logging into multiple NI Web Server using a single browser, the session cookies will clash where the session cookies from the first logging will be overwritten by the next logging due to their session cookies are sharing the same name.

The workaround shared above is to have each of the NI Web Server to use unique name for their session cookies instead of standardized name. This works by preventing the occurrence of overwritten of session cookies due to similar name used.