A few days ago, I migrated a live production website from one VPS to another. It was my first time doing a real server migration. I thought it would be simple. It wasn't.
This blog is a complete breakdown of the architecture, the mistakes I made, the problems I faced, the exact reasoning behind every fix, and what I learned about DNS, Nginx, SSL, and production systems.
The Goal
I had two VPS servers: Old VPS running production + beta, and New VPS meant to run production only.
- Move production to the new VPS
- Keep beta environment on the old VPS
- Make everything work with HTTPS
- Avoid downtime
That's it. Simple on paper.
The Tech Stack
- Frontend: Next.js (running on port 3000 via PM2)
- Backend: NestJS (running on port 8080 via PM2)
- Web Server: Nginx (reverse proxy)
- DNS Provider: Domain registrar DNS panel
- SSL: Let's Encrypt (Certbot)
Step 1: Deploying the App on the New VPS
First, I deployed the frontend and backend to the new VPS. I started the apps using PM2. To verify they were running:
1curl http://localhost:3000It returned the correct HTML. This confirmed the app works, the port is open, and the issue (if any) is not the app itself.
"Always test locally on the server before blaming DNS or Nginx."
Step 2: Configuring Nginx
Nginx acts like a traffic controller. It listens on Port 80 (HTTP) and Port 443 (HTTPS), and forwards traffic to localhost:3000 (frontend) and localhost:8080 (backend).
Once I configured Nginx, I tested it:
1sudo nginx -t
2sudo systemctl restart nginxEverything looked fine. But when I visited the domain...
Problem #1: SSL Certificate Failed
When I tried to generate SSL certificates using Certbot, I got an error. The error message showed something surprising: The domain was still resolving to the OLD server IP. Even though I had updated DNS.
What was happening? DNS propagation. When you change DNS, it does not update instantly worldwide. It takes time.
To verify where a domain points, I used:
1dig domain.com +shortUntil it showed the new server IP, SSL validation would fail.
"Always verify DNS propagation before generating SSL certificates."
Problem #2: Nginx Wouldn't Start (Port Already in Use)
After installing SSL, Nginx refused to start.
1bind() to 0.0.0.0:80 failed (Address already in use)This means something is already using that port. I checked:
1sudo netstat -tulpn | grep :80An old Nginx process was still running. I killed it:
1sudo pkill -9 nginxThen restarted Nginx cleanly.
"Port conflicts are common. Always check which process is holding a port."
Problem #3: Browser Said 'Not Secure' — But Server Was Fine
This one was tricky. From the server, curl -I https://domain.com returned 200 OK. SSL was working. But the browser showed 'Not Secure'.
I opened the site in Incognito mode. It showed 'Secure'. That meant the browser had cached the old security state.
"Browsers cache SSL/HSTS state separately. Always test in incognito before panicking."
Problem #4: Beta Subdomains Broke
After moving production, my beta subdomains stopped working. DNS check revealed something interesting. There was a wildcard DNS record: A * → New Server IP
Wildcard records mean any subdomain not explicitly defined goes to this IP. So beta.example.com was being routed to production server.
Fix: Remove wildcard. Add explicit A records for each subdomain.
"Wildcard DNS is powerful — and dangerous."
What I Learned
This migration taught me more than any tutorial ever did. Here's the real mental model:
When someone types a domain: DNS decides which IP to send traffic to → The server receives the request → Nginx decides which app should handle it → The app responds → SSL ensures encryption
If something breaks, it's usually one of these layers. Debug layer by layer. Never guess. Always verify.
My Biggest Takeaways
- Always test app locally on server first
- Always verify DNS before SSL
- Never trust browser cache
- Avoid wildcard DNS unless necessary
- Clean old servers after migration
- Use curl and dig more than your browser
Final Thoughts
This was my first real production migration. It was stressful. It was confusing. It broke in unexpected ways.
But by the end of it, I wasn't just 'deploying apps' anymore. I understood infrastructure. And that changes everything.

