<?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: Uko Mbereobong</title>
    <description>The latest articles on DEV Community by Uko Mbereobong (@sirvickcloud9).</description>
    <link>https://dev.to/sirvickcloud9</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%2F4213831%2Fc42f7962-70c1-4a47-93f4-dd4601156e06.png</url>
      <title>DEV Community: Uko Mbereobong</title>
      <link>https://dev.to/sirvickcloud9</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sirvickcloud9"/>
    <language>en</language>
    <item>
      <title>How I Fixed NGINX 502 Bad Gateway and Tested Automatic Node.js Recovery on AWS EC2 ---</title>
      <dc:creator>Uko Mbereobong</dc:creator>
      <pubDate>Thu, 29 Oct 2026 23:47:42 +0000</pubDate>
      <link>https://dev.to/sirvickcloud9/how-i-fixed-nginx-502-bad-gateway-and-tested-automatic-nodejs-recovery-on-aws-ec2--1i69</link>
      <guid>https://dev.to/sirvickcloud9/how-i-fixed-nginx-502-bad-gateway-and-tested-automatic-nodejs-recovery-on-aws-ec2--1i69</guid>
      <description>&lt;p&gt;One thing I am learning as I continue my DevOps journey is that deploying an application successfully is only part of the job. Understanding what happens when that application fails is equally important.&lt;/p&gt;

&lt;p&gt;In this hands-on lab, I deliberately broke my Node.js backend on an AWS EC2 Ubuntu server to see how NGINX behaves. The result was the classic &lt;strong&gt;502 Bad Gateway&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I documented the full lab with screenshots on my blog: &lt;br&gt;
&lt;strong&gt;Full tutorial here → &lt;a href="https://blog.sirvickcloud9.online/2026/10/how-i-fixed-nginx-502-bad-gateway-error.html" rel="noopener noreferrer"&gt;https://blog.sirvickcloud9.online/2026/10/how-i-fixed-nginx-502-bad-gateway-error.html&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What I Used&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS EC2 Ubuntu 22.04&lt;/li&gt;
&lt;li&gt;Node.js backend on port 3000&lt;/li&gt;
&lt;li&gt;NGINX 1.24.0 as reverse proxy (port 80 → 127.0.0.1:3000)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Request flow: Browser → NGINX → Node.js&lt;/p&gt;

&lt;p&gt;What Happened&lt;/p&gt;

&lt;p&gt;I stopped the Node.js service and hit my public IP. NGINX was still up but returned 502. That was the key lesson: &lt;strong&gt;502 does not mean NGINX is down. It means NGINX cannot get a valid response from upstream.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;How I Found the Real Cause&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Checked config syntax (this does NOT check if backend is running):&lt;/li&gt;
&lt;/ol&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
bash
sudo nginx -t
2. Checked real error:
sudo tail -n 50 /var/log/nginx/error.log
28906#28906: *10 connect() failed (111: Connection refused) while connecting to upstream, upstream: "http://127.0.0.1:3000/"
3. Verified with curl:
curl -i http://127.0.0.1:3000
curl -i http://127.0.0.1
I explained how I track Linux processes and debug ports with `ps aux | grep node`, `systemctl status` and `netstat -tulpn` in my earlier post about https://blog.sirvickcloud9.online/2025/09/understanding-linux-environment-real.html.

How I Restored and Verified

Instead of just restarting, I verified the actual HTTP response:
curl http://127.0.0.1:3000
Hello! The Node.js backend is working correctly.

curl -i http://127.0.0.1
HTTP/1.1 200 OK
Always verify with real HTTP response, not just `systemctl status`.

The Best Part: Testing systemd Auto-Restart

On Ubuntu, systemd can restart your app automatically:
in nginx-502-lab.service
Restart=on-failure
This is the same systemd approach I used when https://blog.sirvickcloud9.online/2025/10/my-github-actions-self-hosted-runner-kept.html — I fixed it by running it as a systemd service with `svc.sh`.

Check logs:
sudo journalctl -u nginx-502-lab -n 50 --no-pager
My logs showed:
Main process exited, code=killed, status=9/KILL
Scheduled restart job, restart counter is at 1.
Node.js application listening on 127.0.0.1:3000
After auto-restart, curl returned 200 OK again.

Key Lessons

- `sudo nginx -t` checks syntax only, not backend health
- Always check `error.log` for `Connection refused`
- Test both direct backend and through NGINX
- `Restart=on-failure` helps, but you still need monitoring

*I posted the full experiment with 4 screenshots, all commands, and production improvements on my blog:*

*→ Read full lab: https://blog.sirvickcloud9.online/2026/10/how-i-fixed-nginx-502-bad-gateway-error.html*

Thanks for reading SirVick DevOps Diary — I share practical labs from Port Harcourt as I learn AWS, Linux and DevOps.

---
If this saved you time fixing 502, support my next lab: https://app.raenest.com/invoice/payment/RNMX5R3WP

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>aws</category>
      <category>devops</category>
      <category>linux</category>
      <category>ubuntu</category>
    </item>
    <item>
      <title>How I Fixed NGINX 502 Bad Gateway on AWS EC2 tags: nginx, nodejs, aws, devops ---</title>
      <dc:creator>Uko Mbereobong</dc:creator>
      <pubDate>Thu, 29 Oct 2026 23:28:24 +0000</pubDate>
      <link>https://dev.to/sirvickcloud9/how-i-fixed-nginx-502-bad-gateway-on-aws-ec2tags-nginx-nodejs-aws-devops--4iig</link>
      <guid>https://dev.to/sirvickcloud9/how-i-fixed-nginx-502-bad-gateway-on-aws-ec2tags-nginx-nodejs-aws-devops--4iig</guid>
      <description>&lt;p&gt;I deliberately stopped my Node.js backend on AWS EC2 to see what NGINX does. It returned &lt;strong&gt;502 Bad Gateway&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Full lab with 4 screenshots here: &lt;a href="https://blog.sirvickcloud9.online/2026/10/how-i-fixed-nginx-502-bad-gateway-error.html" rel="noopener noreferrer"&gt;https://blog.sirvickcloud9.online/2026/10/how-i-fixed-nginx-502-bad-gateway-error.html&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Setup
&lt;/h3&gt;

&lt;p&gt;EC2 Ubuntu + Node.js on 3000 + NGINX reverse proxy.&lt;/p&gt;

&lt;p&gt;Browser -&amp;gt; NGINX -&amp;gt; Node.js (127.0.0.1:3000)&lt;/p&gt;

&lt;h3&gt;
  
  
  The Key Lesson
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;502 does NOT mean NGINX is down.&lt;/strong&gt; It means NGINX cannot get a valid response from upstream.&lt;/p&gt;

&lt;p&gt;I confirmed with:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
bash
sudo nginx -t
# syntax ok - but this does NOT check backend!

sudo tail -n 20 /var/log/nginx/error.log
# connect() failed (111: Connection refused) while connecting to upstream
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>nginx</category>
      <category>aws</category>
      <category>devops</category>
      <category>backend</category>
    </item>
  </channel>
</rss>
