Error: "The provided API key is expired."
Your Google Maps API server key has expired and needs to be renewed or replaced.
- Go to: https://console.cloud.google.com/apis/credentials
- Find your server API key (
STAIRS Backend Server Keyor similar) - Check if it shows as "Expired" or "Invalid"
-
In Google Cloud Console:
- Go to: https://console.cloud.google.com/apis/credentials
- Click "+ CREATE CREDENTIALS" → "API key"
-
Name it:
STAIRS Backend Server Key v2(or with current date) -
Click "Restrict key" tab:
Application restrictions:
- Select "IP addresses (web servers, cron jobs, etc.)"
- Add your server IP:
160.187.22.41 - Or add Cloudflare IP ranges if needed
API restrictions:
- Select "Restrict key"
- Enable these APIs:
- ✅ Places API
- ✅ Geocoding API
- ✅ Maps JavaScript API (optional, for backend if needed)
-
Click "SAVE"
-
Copy the new API key
Option A: Use helper script:
cd /root/stairs-new
bash quick-fix-server-key.shEnter your new API key when prompted.
Option B: Manual update:
cd /root/stairs-new/backend
# Backup .env
cp .env .env.backup.$(date +%Y%m%d_%H%M%S)
# Edit .env
nano .env
# Find the line:
# GOOGLE_MAPS_API_KEY=old_expired_key
# Replace with:
GOOGLE_MAPS_API_KEY=YOUR_NEW_KEY_HERE
# Save and exit (Ctrl+X, Y, Enter)Option C: Quick command line:
# Replace OLD_KEY with your expired key, NEW_KEY with new key
cd /root/stairs-new/backend
sed -i 's/^GOOGLE_MAPS_API_KEY=.*/GOOGLE_MAPS_API_KEY=YOUR_NEW_KEY_HERE/' .env
# Verify
grep GOOGLE_MAPS_API_KEY .envpm2 restart stairs-backend
# Verify it's running
pm2 logs stairs-backend --lines 20# Test local endpoint
curl "http://localhost:5000/api/maps/places/autocomplete?input=test"
# Should return JSON with predictions, NOT expired error# Check logs for expired errors
pm2 logs stairs-backend --lines 50 | grep -i "expired\|denied"
# Should show no resultsGoogle Maps API keys can expire if:
- Billing issue - Payment method expired or insufficient funds
- Key rotation - Google requires periodic key rotation
- Account suspension - Billing or policy violation
- Project disabled - Project paused or disabled
-
Enable billing alerts:
- Go to Google Cloud Console → Billing → Budgets & alerts
- Set up alerts for API usage
-
Monitor API usage:
- Go to APIs & Services → Dashboard
- Check usage and quotas regularly
-
Keep payment method current:
- Ensure credit card/billing account is active
-
Document your keys:
- Keep track of which keys are used where
- Have backup/recovery plan
- Create new API key in Google Cloud Console
- Set IP restrictions (NOT referer restrictions)
- Enable Places API and Geocoding API
- Update
GOOGLE_MAPS_API_KEYinbackend/.env - Restart backend:
pm2 restart stairs-backend - Test endpoint:
curl http://localhost:5000/api/maps/places/autocomplete?input=test - Verify no expired errors in logs
- Test frontend venue autocomplete
- Verify key is not restricted to referrers (must be IP or no restrictions)
- Verify Places API is enabled in API restrictions
- Verify billing is enabled for Google Cloud project
- Verify quota hasn't been exceeded
pm2 logs stairs-backend --lines 100 | grep -i "google\|places\|api\|error"Once you create the new key and update the backend, the expired errors should be resolved!