How to Fix Website Changes Not Showing in Next.js | A Step By Step Solution | Web Engineering Notes
How to Fix Website Changes Not Showing in Next.js | A Step By Step Solution
Jan 21, 2026
Next.jsCachingStatic ContentPM2
Table of Contents
Introduction
Causes
Next.js Build Issue
Static Content Caching Issue
Static Content
Caching
PM2 Process Issue
Next.js Build Issue – How to Fix
Static Content Caching Issue – How to Fix
PM2 Process Issue – How to Fix
Introduction
Have you ever changed your code but did not see the actual changes? The browser still shows the older version. You are not alone — I faced this issue myself and it often cost me hours trying to fix. Once you understand the real cause, you can solve this issue in a couple of minutes. In this blog, I will guide you step by step so you can solve it yourself.
Causes
In order to solve the problem we need to understand what causes it. While it can occur in both frontend and backend, it is more common in the frontend, especially with Nextjs. Here are some common causes:
1. Next.js Build Issue (Frontend)
Sometimes changes do not appear because developers don't update the production build in Nextjs after editing the code.
Related Articles
Next.js + FastAPI Tutorial: Connect Frontend to Backend Step-by-Step
In this tutorial, you will learn how to connect a Next.js frontend to a FastAPI backend. We will build a simple full-stack application where the frontend fetches data from an API and displays it in the UI. You will also learn how to handle CORS, fetch API data, and understand how frontend and backend communicate in modern web applications.
Subscribe to get the latest articles delivered directly to your inbox.
2. Static Content Caching Issue (Browser)
Browsers still may show the old cached static content inside the memory instead of new static content.
3. PM2 Process Issue (Server)
PM2 may still run the old code in memory and developers forget to restart or just restart incorrectly.
If you have clearly understood the causes, we can move further to solve each cause in detail one by one.
Next.js Build Issue – How To Fix
In nextjs we must build the production code to run a production server. Usually the flow of nextjs server deployment is:
bash
npm install # To installing node modulesnpm run build # To build the optimized production codenpm run start # To start the production server
These commands are required for the first deployment of Nextjs Server. After making some changes we must run the command npm run build. Most developers just skip this step and only run the npm run start command.
If you skip the build step the server will continue running on the old build, so changes won’t appear.
To see the changes you must run npm run build and then npm run start. Otherwise the issue will persist. So the flow after editing the code should be:
bash
npm run buildnpm run start
If you follow these steps you will never face the issue again unless it is a caching issue which we will discuss below.
Static Content Caching Issue – How To Fix
To understand and solve this issue, we first need to understand:
1. Static Content
2. Caching
Static Content
Static content is content on a webpage that does not change with user interaction. This includes HTML, CSS, images and JS files. To fully understand the issue, we also need to understand caching.
Caching
Caching is the process of storing Static Content inside a very fast storage, usually RAM to quickly access it instead of fetching it from the server every time. This enhances the user experience and loads the content faster from RAM.
Now that we have understood these terms. Let’s understand how static content can prevent updated code from appearing in the browser.
Usually when we change or edit the code or any static content like static Images, Logos, HTML or JS file, these files are already cached by the browser and it shows old static content stored in RAM rather than fetching from the server.
This old cached content is the actual reason you are not seeing changes you want. To fix this we need to remove the old cache from the browser so that it fetches the new Static content and cache it.
To remove the old static content you can perform the following steps.
Hard refresh: Ctrl + F5 (Windows) / Cmd + Shift + R (Mac)
Open in Incognito mode to bypass browser cache
By performing these steps you must be able to see the changes.
Remember:
Browser caching is not permanent. After the defined time for cache content the browser usually refetch the fresh content automatically from the server. So after some time you will see the changes.
If you are still facing the issue then the problem would be from the process manager like PM2 only if you are using it. The PM2 issue is discussed below.
PM2 Process Issue – How To Fix
If you are using a process manager like PM2 for your Nextjs production server, the issue often occurs because the old process was not stopped and restarted properly.
When using PM2 we don't run npm run start command directly after npm run build we use a PM2 command like:
bash
pm2 start npm --name "your-app-name" -- run start
So when we make changes in the code we need to perform the following commands in order to see the changes.
bash
pm2 stop your-apppm2 delete your-appnpm run buildpm2 start npm --name "your-app-name" -- run start
By performing these steps you should be able to see the changes.
If your website shows a 502 Bad Gateway error after restarting, the issue might be related to your Nginx server configuration. You can fix that problem by following this detailed guide on how to fix 502 Bad Gateway errors
Frequently Asked Questions (FAQ)
1. Do I need to run npm run build after every code change in Next.js?
Yes.
In a production environment, Next.js serves the build version of your app.
If you change the code and don't run npm run build, the server will continue running the old build and your changes will not appear.
2. Why do I still see the old content even after restarting the server?
This usually happens because of browser caching.
Your browser may still be loading the old cached static content instead of fetching the updated ones from the server.
Try a hard refresh or open the site in incognito mode.
3. Is restarting PM2 enough to apply new changes?
Not always.
If the old process is still running in memory, simply restarting may not work properly.
The safest approach is to ** stop, delete, rebuild and then start ** the PM2 process again.
4. Can this issue cause a 502 Bad Gateway error?
Indirectly, Yes.
If your backend process or PM2 is not running properly, Nginx may fail to connect to it and return a 502 Bad Gateway error.
Conclusion
Once you understand the real cause of the problem, debugging no longer feels difficult. In most cases, website changes not showing after restart are caused by missing build steps, browser caching, or an improper restart of a process manager like PM2.
If you carefully follow the steps explained in this blog, you should be able to identify and fix the issue within minutes. If you are still facing a related problem, feel free to contact me through the contact page.
If you find this blog helpful, please share it with others and subscribe to the newsletter for more practical and valuable content.