Display Node.js Errors on a Windows IIS Server

Today I was working on a Node server that runs on a Windows server with IIS. I ran into a problem where I wanted my 404 errors to actually send a 404 result with a custom page created in Node. Sending a 404 error made IIS want to display its custom 404 error page though.

I learned you can get around this by adjusting your web.config file. Locate your <system.webServer> settings and add the following snippet: <httpErrors existingResponse="PassThrough" />. This leaves the response untouched if an existing response exists per.

Side note, I highly recommend using the IIS Node package if you are one of the rare people who have to run this setup.

Matt Ferderer

Software enginner who spends his time learning about building teams, project management, software architecture, C#, .NET Core, Blazor, JavaScript, TypeScript, Azure, user experience, web security, and performance.