<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Winton De Villiers</title>
    <description>The latest articles on DEV Community by Winton De Villiers (@winton_devilliers_6e31f1).</description>
    <link>https://dev.to/winton_devilliers_6e31f1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2770819%2F6c3819bc-69fb-42f0-89e9-0ed082157c4b.jpg</url>
      <title>DEV Community: Winton De Villiers</title>
      <link>https://dev.to/winton_devilliers_6e31f1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/winton_devilliers_6e31f1"/>
    <language>en</language>
    <item>
      <title>When Your API Says "Unavailable" But Still Works: A Junior Dev's Troubleshooting Adventure (IIS, NEXT.js v13, STRAPI)</title>
      <dc:creator>Winton De Villiers</dc:creator>
      <pubDate>Fri, 21 Feb 2025 12:00:17 +0000</pubDate>
      <link>https://dev.to/winton_devilliers_6e31f1/when-your-api-says-unavailable-but-still-works-a-junior-devs-troubleshooting-adventure-iis-32mh</link>
      <guid>https://dev.to/winton_devilliers_6e31f1/when-your-api-says-unavailable-but-still-works-a-junior-devs-troubleshooting-adventure-iis-32mh</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Imagine this: You're deep into developing your &lt;strong&gt;Strapi&lt;/strong&gt; and &lt;strong&gt;Next.js v13&lt;/strong&gt; application, happily testing your API, when suddenly, the browser smacks you with a &lt;strong&gt;503 Service Unavailable&lt;/strong&gt; error. Panic starts creeping in. But then you check your API response manually, and—surprise!—your API is still returning data.  &lt;/p&gt;

&lt;p&gt;What’s going on?  &lt;/p&gt;

&lt;p&gt;This post takes you through my troubleshooting journey, from confusion to resolution, as I tackled this weird issue while deploying &lt;strong&gt;Strapi&lt;/strong&gt; on an &lt;strong&gt;IIS server with a reverse proxy and PM2&lt;/strong&gt;. Along the way, I’ll share lessons learned and why &lt;strong&gt;Nginx&lt;/strong&gt; might have been a better choice from the start.  &lt;/p&gt;




&lt;h2&gt;
  
  
  The Problem: The 503 Enigma
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What I Saw
&lt;/h3&gt;

&lt;p&gt;I deployed my &lt;strong&gt;Strapi API&lt;/strong&gt; on a server running &lt;strong&gt;IIS&lt;/strong&gt; with a &lt;strong&gt;reverse proxy&lt;/strong&gt;. Everything seemed fine at first, but then:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The browser displayed a "503 Service Unavailable" error.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;However, direct API calls via Postman or &lt;code&gt;fetch()&lt;/code&gt; still returned data.&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The browser console screamed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GET http://xx.xx.xx.xx:8000/api/sales 503 (Service Unavailable)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But when I manually checked via &lt;strong&gt;Postman&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "data": [...],
  "meta": {...}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The API was clearly still responding. So why was IIS throwing a 503?  &lt;/p&gt;




&lt;h2&gt;
  
  
  The Troubleshooting Journey
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1️⃣ Initial Steps: Where to Begin?
&lt;/h3&gt;

&lt;p&gt;I started by checking the usual suspects:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Strapi logs (&lt;code&gt;pm2 logs strapi&lt;/code&gt;)&lt;/strong&gt; – Nothing unusual.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reverse proxy logs (IIS logs &amp;amp; Event Viewer)&lt;/strong&gt; – No clear signs of failure.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Restarting the Strapi service (&lt;code&gt;pm2 restart strapi&lt;/code&gt;)&lt;/strong&gt; – No effect.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Everything &lt;strong&gt;seemed&lt;/strong&gt; fine… but clearly, something was wrong.  &lt;/p&gt;




&lt;h3&gt;
  
  
  2️⃣ Resource Monitoring: A CPU Clue
&lt;/h3&gt;

&lt;p&gt;Next, I checked &lt;strong&gt;server resource usage&lt;/strong&gt; using &lt;strong&gt;PM2 and system tools&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pm2 list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Boom. &lt;strong&gt;CPU usage was abnormally high.&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;Strapi was running, but it was &lt;strong&gt;struggling under load&lt;/strong&gt;, possibly affecting IIS’s ability to serve requests.  &lt;/p&gt;




&lt;h3&gt;
  
  
  3️⃣ IIS and Reverse Proxy Deep Dive
&lt;/h3&gt;

&lt;p&gt;IIS can be tricky, especially with &lt;strong&gt;reverse proxy configurations&lt;/strong&gt;. Here’s what I checked:  &lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Application Pool Settings&lt;/strong&gt; – Ensured the pool was running.&lt;br&gt;&lt;br&gt;
✅ &lt;strong&gt;URL Rewrite Rules&lt;/strong&gt; – Verified they were forwarding requests correctly.&lt;br&gt;&lt;br&gt;
✅ &lt;strong&gt;IIS Logs (&lt;code&gt;C:\inetpub\logs\LogFiles&lt;/code&gt;)&lt;/strong&gt; – Found a &lt;strong&gt;5002 error&lt;/strong&gt;!  &lt;/p&gt;

&lt;p&gt;The key clue was in &lt;strong&gt;Windows Event Viewer&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Microsoft-Windows-WAS Error 5002: Application pool for Strapi has been disabled due to repeated failures.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  4️⃣ The Culprit: Application Pool Issues
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What happened?&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;🔍 &lt;strong&gt;IIS application pool had stopped&lt;/strong&gt; due to high CPU usage and repeated failures.&lt;br&gt;&lt;br&gt;
🔍 Windows automatically &lt;strong&gt;disabled&lt;/strong&gt; the pool to prevent further issues.  &lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Restarting the application pool manually resolved the 503 error!&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;iisreset&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/restart&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But… this was only a &lt;strong&gt;temporary fix&lt;/strong&gt;.  &lt;/p&gt;




&lt;h3&gt;
  
  
  5️⃣ IIS vs. Nginx: Considering a Better Solution
&lt;/h3&gt;

&lt;p&gt;While IIS works, &lt;strong&gt;Nginx is much better suited for Node.js applications like Strapi&lt;/strong&gt;. Here’s why:  &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;IIS&lt;/th&gt;
&lt;th&gt;Nginx&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Performance&lt;/td&gt;
&lt;td&gt;Slower for Node.js apps&lt;/td&gt;
&lt;td&gt;Faster, optimized for Node.js&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reverse Proxy&lt;/td&gt;
&lt;td&gt;More complex setup&lt;/td&gt;
&lt;td&gt;Easier &amp;amp; more efficient&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stability&lt;/td&gt;
&lt;td&gt;Can crash under high load&lt;/td&gt;
&lt;td&gt;Handles high traffic better&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Configuration&lt;/td&gt;
&lt;td&gt;GUI-based, less flexible&lt;/td&gt;
&lt;td&gt;Config files, more control&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;👉 &lt;strong&gt;In the long run, switching to Nginx could prevent these issues.&lt;/strong&gt;  &lt;/p&gt;




&lt;h2&gt;
  
  
  The Solution and Lessons Learned
&lt;/h2&gt;

&lt;h3&gt;
  
  
  ✅ Immediate Fix
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Restarted the IIS application pool manually.
&lt;/li&gt;
&lt;li&gt;Lowered Strapi’s resource usage by optimizing queries.
&lt;/li&gt;
&lt;li&gt;Used &lt;strong&gt;PM2 process limits&lt;/strong&gt; to prevent overload:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pm2 start strapi &lt;span class="nt"&gt;--max-memory-restart&lt;/span&gt; 200M
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Key Takeaways
&lt;/h3&gt;

&lt;p&gt;✔ &lt;strong&gt;Check logs early&lt;/strong&gt; – IIS logs and Event Viewer revealed the real issue.&lt;br&gt;&lt;br&gt;
✔ &lt;strong&gt;Monitor resource usage&lt;/strong&gt; – PM2 helped catch high CPU usage.&lt;br&gt;&lt;br&gt;
✔ &lt;strong&gt;Understand your hosting environment&lt;/strong&gt; – IIS behaves differently from Nginx.&lt;br&gt;&lt;br&gt;
✔ &lt;strong&gt;Consider switching to Nginx&lt;/strong&gt; – A better long-term solution for Node.js apps.  &lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Troubleshooting this issue was frustrating but ultimately rewarding. &lt;strong&gt;Understanding how IIS, Strapi, and the reverse proxy interact&lt;/strong&gt; was crucial in solving it.  &lt;/p&gt;

&lt;p&gt;If you’re a junior dev running into weird &lt;strong&gt;503 errors&lt;/strong&gt;, &lt;strong&gt;always check your server logs, application pools, and CPU usage.&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;Have you had a similar experience? Share your story in the comments! &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>iis</category>
      <category>nextjs</category>
    </item>
  </channel>
</rss>
