Skip to main content

Appendix: Hosting Options

This guide presents the different options for hosting your Spring Boot API, from local development to production.


1. Local Development (Free)​

For development and testing, you need nothing more than your computer.

ComponentLocal Solution
Application./mvnw spring-boot:run
DatabaseH2 (in memory)
EmailsMailHog (Docker)
# Start MailHog to test emails
docker run -d -p 1025:1025 -p 8025:8025 mailhog/mailhog

# Start the application
./mvnw spring-boot:run

# Access the API: http://localhost:8080
# View emails: http://localhost:8025

Cost: $0


2. Why not Vercel?​

Vercel is excellent for frontends (React, Next.js, Vue) but does not support Spring Boot:

CriteriaVercelSpring Boot
LanguagesNode.js, Python, GoJava
TypeServerless / FrontendTraditional Backend
JVMNot supportedRequired

Vercel = Frontend | Railway/Render/Heroku = Java Backend

If you have a React frontend + Spring Boot backend:

  • Frontend → Vercel (free)
  • Backend → Railway or Render (free)

3. Free Cloud Options (limited)​

Railway​

FeatureDetail
URLhttps://railway.app
Free500 hours/month + $5 credit
PostgreSQLIncluded for free
DeploymentAutomatic GitHub connection
DifficultyEasy
# Deploy on Railway
# 1. Connect your GitHub repo
# 2. Railway automatically detects Spring Boot
# 3. Add environment variables
# 4. Automatic deployment!

Render​

FeatureDetail
URLhttps://render.com
Free750 hours/month (spin down after 15 min)
PostgreSQLFree for 90 days
DeploymentGitHub or Docker
DifficultyEasy

Fly.io​

FeatureDetail
URLhttps://fly.io
Free3 shared VMs
PostgreSQL3GB free
DeploymentCLI or Dockerfile
DifficultyMedium

4. Cheap VPS Hosting​

Hostinger VPS​

PlanRAMCPUStoragePrice
KVM 14 GB1 vCPU50 GB$4.99/month
KVM 28 GB2 vCPU100 GB$8.99/month
KVM 416 GB4 vCPU200 GB$14.99/month

Hostinger Advantages:

  • Very competitive prices
  • Simple management panel
  • 24/7 support
  • Free snapshots

Installation on Hostinger VPS:

# 1. Connect via SSH
ssh root@your-ip

# 2. Install Docker
curl -fsSL https://get.docker.com | sh

# 3. Install Docker Compose
apt install docker-compose -y

# 4. Clone your project
git clone https://github.com/your-user/your-project.git
cd your-project

# 5. Start with Docker
docker-compose up -d

DigitalOcean​

PlanRAMCPUStoragePrice
Basic1 GB1 vCPU25 GB$6/month
Basic2 GB1 vCPU50 GB$12/month
Basic4 GB2 vCPU80 GB$24/month

Bonus: $200 free credit for students via GitHub Education.

Hetzner​

PlanRAMCPUStoragePrice
CX112 GB1 vCPU20 GB€3.29/month
CX214 GB2 vCPU40 GB€5.83/month
CX318 GB2 vCPU80 GB€10.59/month

The cheapest in Europe!

OVH​

PlanRAMCPUStoragePrice
Starter2 GB1 vCPU20 GB€3.50/month
Essential4 GB2 vCPU40 GB€6.50/month

5. Platform as a Service (PaaS)​

Heroku​

PlanDetailPrice
Eco1000 shared hours/month$5/month
BasicAlways on$7/month
StandardPerformance$25/month

Heroku PostgreSQL:

  • Mini: Free (10K rows)
  • Basic: $9/month
  • Standard: $50/month

Google Cloud Run​

FeatureDetail
Free2 million requests/month
Price$0.00002/request after
ScalingAutomatic (0 to N)

Ideal if you have low traffic!


6. Price Comparison​

Cheapest Options​

RankServicePrice/monthType
1Hetzner CX11€3.29VPS
2OVH Starter€3.50VPS
3Hostinger KVM 1$4.99VPS
4Railway$5 creditCloud
5Heroku Eco$5PaaS
6DigitalOcean$6VPS

Free for Students​

ServiceStudent Offer
GitHub EducationDigitalOcean $200, Heroku, etc.
Azure for Students$100 credit
Google Cloud$300 credit
AWS EducateVariable credit

7. Recommendations by Use Case​

For a Student Project​

Recommended: Railway or Render (free)
Alternative: Heroku Eco ($5/month)

For a Personal Portfolio​

Recommended: Hostinger VPS ($4.99/month)
Alternative: Hetzner (€3.29/month)

For a Startup / Production​

Recommended: DigitalOcean or Hetzner
Alternative: Google Cloud Run (pay-per-use)

8. Production Configuration​

Required Environment Variables​

# Database
DB_HOST=localhost
DB_PORT=5432
DB_NAME=contactdb
DB_USER=postgres
DB_PASSWORD=secure_password

# Email (example with Gmail)
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USER=your@gmail.com
MAIL_PASSWORD=app_password

# JWT
JWT_SECRET=your_base64_256bits_secret_key
JWT_EXPIRATION=86400000

# Admin
ADMIN_EMAIL=admin@yourdomain.com

With Nginx (reverse proxy)​

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

location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}

With HTTPS (Let's Encrypt)​

# Install Certbot
apt install certbot python3-certbot-nginx -y

# Obtain free SSL certificate
certbot --nginx -d api.yourdomain.com

9. Deployment Checklist​

  • Choose a host
  • Create the server/instance
  • Install Docker
  • Configure environment variables
  • Deploy with docker-compose up -d
  • Configure a domain name (optional)
  • Enable HTTPS (optional but recommended)
  • Test the endpoints

10. Cheap Domains​

Registrar.com Price.dev Price
Namecheap~$9/year~$15/year
Porkbun~$9/year~$13/year
Cloudflare~$9/year (cost)~$11/year
OVH~€10/year~€15/year

Tip: Cloudflare sells domains at cost price (no markup).


Summary​

BudgetRecommendation
$0Railway / Render / Local
~$5/monthHeroku Eco or Hostinger
~$10/monthDigitalOcean or Hetzner
StudentGitHub Education ($200 free)

Back to Option E