Deploying my Next.js portfolio on AWS
After setting up the domain and HTTPS, I deployed the Next.js version of my portfolio to EC2. This post covers that January 2026 setup and the problems I worked through.
Getting the code onto the server
I kept the project in GitHub and cloned it onto the server. An incorrect remote URL initially caused a “Repository not found” error. Updating the URL with git remote set-url fixed it.
Matching the environment
The server was running Node.js 18. I used NVM to switch to Node.js 20 for this deployment, then installed the dependencies and built the app.
nvm install 20
nvm use 20
npm install
npm run buildBuilding on a small EC2 instance also meant paying attention to memory usage. Keeping the local and server environments consistent made build failures easier to diagnose.
Running the app with PM2
I used PM2 to manage the app process after closing my SSH session. I saved the process list and used the startup command to configure it to start after a reboot.
pm2 start npm --name "portfolio" -- start
pm2 save
pm2 startupThe startup command prints a system-specific command to complete the setup. Saving the process list alone does not configure reboot startup.
Routing traffic with Nginx
Nginx handled incoming web requests and forwarded them to the Next.js app on port 3000. This kept the domain and HTTPS configuration separate from the application process.
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
}Updating the site
My update process was manual: push the code to GitHub, pull it on the server, rebuild, and restart the PM2 process. Working through each step helped me understand where a deployment could fail.
The most useful lesson was to check the build environment, app process, and reverse proxy separately when something went wrong.
View the AWS project →