Skip to content

Practices and debugging small deployments

Published: at 08:40 PMSuggest Changes

Deploying side projects and prototypes? Whether you’re pushing code manually to an EC2 instance or using free hosting services like Vercel, Netlify, or Render, things can get tricky. This blog is all about debugging side/small deployment and service configuration.

Table of contents

Open Table of contents

Before code push

For many side projects, developers prefer serverless deployment platforms like Vercel, Netlify, or Render. These platforms require minimal configuration—connect your GitHub repo, and boom, it’s live! But there are some key things to watch for:

  1. Set the Right Build Command: If you’re using React or another framework, ensure the build command matches your project. Edit it if necessary (e.g., npm run build).

  2. Avoid Hardcoding Secrets: No API keys should be visible in your code. Use environment variables instead.

  3. Organize Static Files: Keep static assets in the /public folder so the platform can serve them properly.

Network and Configuration Challenges

Security Group Rules

On AWS EC2, ensure inbound and outbound rules in your security group allow necessary ports (e.g., 80 for HTTP, 443 for HTTPS, or 3000 for development servers).

Firewall Issues

Check the firewall settings on your VM. Temporarily disable the firewall to determine if it’s causing the problem:

Disable: sudo ufw disable Enable: sudo ufw enable Allow specific ports: sudo ufw allow [PORT] Check status: sudo ufw status

Port Forwarding Problems

Use curl on EC2 to test if the app is running on the expected port (e.g., curl localhost:3000).

If the app works locally but fails externally,Check your endpoint using port itself like yourdomain.com:3000/api/v1/fetch if it works which means there are issues which nginx configuration.

if you see endpoint not hitting your service, check you nginx or webserver config. for nginx look into /etc/nginx/sites-enabled/default or etc/nginx/sites-enabled/your-site.com here is basic configurations for nginx

server {
    listen 80;
    server_name api.yourdomain.com;

    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;
        proxy_cache_bypass $http_upgrade;
    }
}

test using sudo nginx -t

restart nginx sudo systemctl reload nginx

HTTP and HTTPS issues

When testing, you might use HTTP, but production apps often require HTTPS. To add an SSL certificate using Let’s Encrypt:

sudo apt install certbot python3-certbot-nginx
sudo  certbot --nginx -d yourdomain.com -d subdomain.domain.com

Domain/Subdomain check

Add an A or CNAME record in your domain provider’s dashboard pointing to your VM’s public IP.

Update the Nginx configuration to include the new domain or subdomain.

Automating Deployment Tasks

  1. Create a Deployment Script
# deploy.sh
echo "Starting deployment..."
git pull origin main
npm install
npm run build
sudo systemctl restart nginx
echo "Deployment complete"

save and hit bash deploy.sh


All these are deployment and network related issues, what if there are issues with project itself ??? We need a process manager for stable deployment, we can use PM2 to keep out application running and check application level logs

If any endpoint crashes the webserver, PM2 will takecare of it and restart the service

npm install pm2@latest -g
pm2 start server.js --name my-app
pm2 startup
pm2 save
pm2 list
pm2 logs my-app

Wrapping Up

Debugging deployments isn’t always fun, but it doesn’t have to be overwhelming. By setting up Nginx, managing firewalls, configuring domains, and using process managers like PM2, you’ll be on your way to reliable deployments. Got your own tips or questions? Share them in the comments


Next Post
HTTP server in Go