How to Self-Host Coolify on AWS EC2 (Complete Guide 2025)

We all love the Vercel or Heroku developer experience. You push code to GitHub, and magic happens: your app is built, deployed, and SSL is provisioned automatically.

But that magic comes at a price. As your project scales, usage limits and per-seat pricing can hit your budget hard.

Coolify is an open-source, self-hosted alternative to Vercel, Netlify, and Heroku. It gives you that same “push-to-deploy” experience but runs on your own infrastructure. You pay for the server, not the seat.

In this guide, I will show you how to set up a production-ready Coolify instance on AWS EC2 using Ubuntu 24.04. By the end of this tutorial, you will have your own private PaaS (Platform as a Service) ready to host Next.js, Node.js,

In this guide, I will show you how to set up a production-ready Coolify instance on AWS EC2 using Ubuntu 24.04. By the end of this tutorial, you will have your own private PaaS (Platform as a Service) ready to host Next.js, Node.js, PHP, and databases—all for the cost of a single EC2 instance.

Prerequisites

Before we start, make sure you have:

  • An active AWS Account (Free tier is okay for testing, but we need a bit more power for Coolify).
  • A Domain Name (You can use Route53, Namecheap, or Cloudflare).
  • Basic SSH Knowledge (You should know how to use a .pem file).

Step 1: Provisioning the EC2 Instance

Coolify runs everything inside Docker containers. Because of this, the “Free Tier” t2.micro (1GB RAM) is not recommended. It will likely crash during builds. For a stable experience, we will use a t3.small.

  1. Log in to your AWS Console and navigate to EC2.
  2. Click Launch Instance.
  3. Name: Give it a recognizable name, like coolify-server.
  4. AMI (OS): Select Ubuntu and choose Ubuntu Server 24.04 LTS (HVM), SSD Volume Type.
  5. Instance Type: Select t3.small (2 vCPU, 2GB RAM).Note: If you are testing, you can try “t2.small“, but t3 instances offer better burst performance for build processes.
  6. Key Pair: Create a new key pair (e.g., coolify-key) or select an existing one. Download the .pem file and keep it safe.
  7. Storage: Increase the Root Volume to at least 20GB gp3. Docker images can take up space quickly.

Step 2: Configuring the Security Group

This is the most critical step. Coolify needs specific ports open to function as a dashboard and to route traffic to your deployed apps.

In the Network settings section of the launch wizard, click “Edit” (or create a new Security Group) and add the following Inbound Rules:

TypePort RangeSourceDescription
SSH22My IP / AnywhereFor server management
HTTP80Anywhere (0.0.0.0/0)Standard Web Traffic
HTTPS443Anywhere (0.0.0.0/0)SSL Traffic
Custom TCP8000Anywhere (0.0.0.0/0)Coolify Dashboard (Initial Setup)
Custom TCP6001Anywhere (0.0.0.0/0)Real-time Service Updates (Optional)

Once configured, click Launch Instance.

Step 3: Server Preparation & Swap Memory

Wait for your instance state to turn to Running. Copy the Public IPv4 address.

Open your terminal and SSH into the server:

ssh -i "path/to/your-key.pem" ubuntu@<your-ec2-ip>

⚠️ Important: Since we are using a server with 2GB of RAM, we must enable Swap Memory. Without this, your server will likely run out of memory (OOM) when Docker tries to build a Next.js or Laravel app, causing the installation or deployment to fail.

Run the following commands to create a 4GB Swap file:

# 1. Switch to root
sudo su

# 2. Allocate 4GB of space
fallocate -l 4G /swapfile

# 3. Secure the file permissions
chmod 600 /swapfile

# 4. Create and enable swap
mkswap /swapfile
swapon /swapfile

# 5. Make it permanent (so it survives reboots)
echo '/swapfile none swap sw 0 0' | tee -a /etc/fstab

# 6. Optimize Swappiness (Use RAM first, then Swap)
sysctl vm.swappiness=10
echo 'vm.swappiness=10' | tee -a /etc/sysctl.conf

Step 4: Installing Coolify

Now that the server is prepped, installing Coolify is incredibly simple. They provide a single command that installs Docker, configures the environment, and sets up the dashboard.

Still logged in as root (or using sudo), run:

curl -fsSL https://cdn.coollabs.io/coolify/install.sh | bash

What happens next? The script will take about 2 to 5 minutes to run. It will:

  1. Install Docker Engine (if not present).
  2. Pull the necessary Coolify Docker images.
  3. Start the Coolify proxy (Traefik) and the Database.

Once the script finishes, you will see a success message looking something like this:

“Coolify installed successfully!” Visit http://<your-ip>:8000 to get started.

Don’t close your terminal yet; we will need it for one last check in the next step.

Step 5: Elastic IP & DNS Configuration

This step distinguishes a “hobby” setup from a professional one. By default, if you stop and start your EC2 instance, AWS assigns a new public IP address, breaking your site. We need to fix that.

1. Allocate an Elastic IP:

  • In the AWS Console (EC2 Dashboard), go to Network & Security -> Elastic IPs in the left sidebar.
  • Click Allocate Elastic IP address.
  • Click Allocate.

2. Associate with your Instance:

  • Select the newly created IP address.
  • Click Actions -> Associate Elastic IP address.
  • Instance: Choose your coolify-server instance.
  • Click Associate.

3. Configure DNS: Now, go to your domain registrar (Route53, Cloudflare, Namecheap, etc.). You need to point your domain to this new Elastic IP.

Create an A Record:

  • Name: @ (or coolify If you want it on a subdomain like coolify.yourdomain.com)
  • Value/Target: Paste your Elastic IP.
  • TTL: Automatic or 1 min.

Pro Tip: If you plan to host multiple apps on this server (e.g., app1.yourdomain.com, api.yourdomain.com), create a Wildcard A Record as well.

  • Name: *
  • Value: Your Elastic IP.

Step 6: Server Preparation & Swap Memory (Vital Step)

If you are using a smaller instance type, like a t3.small (2GB RAM) or even a t3.medium, this step is mandatory.

Coolify builds your applications using Docker. The build process (especially for Next.js or Node apps) can spike memory usage. If you run out of RAM, the Linux OOM (Out of Memory) killer will shut down your database or the deployment process, leaving you with a failed build.

To fix this, we need to add Swap Space (virtual memory on the disk).

1. SSH into your server:

ssh -i "your-key.pem" ubuntu@your-ec2-ip

2. Switch to the root user:

sudo -i

3. Check if you already have swap (usually empty on fresh EC2s):

free -h

4. Create a 4GB Swap file: Run the following commands one by one. I recommend 4GB of swap for a 2GB RAM server.

# Allocate the file space
fallocate -l 4G /swapfile

# Secure the file so only root can access it
chmod 600 /swapfile

# Mark the file as swap space
mkswap /swapfile

# Enable the swap
swapon /swapfile

5. Make it permanent: By default, swap disables after a reboot. Run this command to ensure it stays active after restarts:

echo '/swapfile none swap sw 0 0' | tee -a /etc/fstab

6. Tune the “Swappiness” (Optional but Recommended): By default, Linux swaps aggressively. For a server, we want it to use physical RAM as much as possible and only use Swap when necessary. Set the value to 10.

sysctl vm.swappiness=10
echo 'vm.swappiness=10' | tee -a /etc/sysctl.conf

7. Verify everything: Run free -h again. You should now see 4GB listed in the “Swap” row.

              total        used        free      shared  buff/cache   available
Mem:          1.9Gi       180Mi       1.2Gi       1.0Mi       540Mi       1.6Gi
Swap:         4.0Gi          0B       4.0Gi

Now your server is bulletproof against memory spikes during deployment!

Step 7: Deploying Your First Application (Next.js Example)

Let’s put this to the test by deploying a simple Next.js application.

  1. Connect a Source:
    • On the dashboard, click + Add New (or “Sources”).
    • Select GitHub.
    • You can create a GitHub App (recommended for private repos) or use a Public Repository. For this guide, let’s assume a Public Repo or a simple connection.
  2. Create a Resource:
    • Go to Projects -> Default Project.
    • Click + New -> Public Repository.
    • Paste a Next.js repo URL (e.g., https://github.com/vercel/nextjs-subscription-payments or your own).
    • Click Check Repository.
  3. Configuration:
    • Build Pack: Coolify usually auto-detects this (e.g., Nixpacks). Nixpacks is excellent—it figures out you are using Node/Next.js and installs dependencies automatically.
    • Port: Default is 3000 for Next.js.
    • Domains: In the “Domains” field, enter your full domain, e.g., https://myapp.atiqur.xyz
      • Note: By adding “https://” Coolify knows to automatically request a Let’s Encrypt SSL certificate for you.
  4. Deploy:
    • Click Deploy.
    • Click the Logs tab to watch the magic. You will see it cloning, installing dependencies (npm install), and building (npm run build).

Once the logs say “Healthy”, visit your domain (https://myapp.atiqur.xyz). You should see your app running with a secure HTTPS lock icon!

Conclusion

Congratulations! You have successfully broken free from expensive per-user pricing models. You now have a t3.small EC2 instance running Coolify, giving you a Vercel-like experience for roughly $15-$20/month (depending on your region and reserved instance savings), regardless of how many apps or hobby projects you deploy.

Atiqur Rahman

I am MD. Atiqur Rahman graduated from BUET and is an AWS-certified solutions architect. I have successfully achieved 6 certifications from AWS including Cloud Practitioner, Solutions Architect, SysOps Administrator, and Developer Associate. I have more than 8 years of working experience as a DevOps engineer designing complex SAAS applications.

Leave a Reply