PostgreSQL Connection Refused on Replit
Your application fails to connect to PostgreSQL with a connection refused error. The database service is either not running or your connection string is incorrect.
Replit's PostgreSQL requires the correct credentials, port, and hostname which vary between development and production.
Error Messages You Might See
Common Causes
- PostgreSQL service not started in Replit
- Wrong hostname (localhost vs network hostname)
- Incorrect port number in connection string
- Missing or wrong database credentials
- Database doesn't exist yet (migration not run)
How to Fix It
Verify PostgreSQL is running via Replit's database panel. Use the auto-generated connection string from Replit secrets. For Spring Boot, ensure spring.datasource.url, username, and password are correctly set. Run database migrations on first deploy using Flyway or Liquibase.
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
How do I start PostgreSQL on Replit?
PostgreSQL auto-starts. Click the Database tab to verify it's running
Where's my PostgreSQL connection string?
In Replit Secrets as DATABASE_URL or similar. Copy it to your .env