2 months ago
# Railway TimescaleDB Template Bug Report
## Issue Summary
The TimescaleDB template (https://railway.app/template/timescale) fails to initialize properly, resulting in a broken database that cannot accept external connections.
## Template Information
- Template: TimescaleDB
- Template URL: https://railway.app/template/timescale
- Deployment Date: October 8, 2025
- PostgreSQL Version: 16.10 on x86_64-pc-linux-musl
## Problem Description
### Symptoms
1. Database deploys and shows "Active" status with green checkmark
2. External connections via TCP proxy fail with ECONNRESET error
3. All connection attempts timeout or are refused
4. The TimescaleDB extension is NOT installed despite the template claiming to include it
### Root Cause (from logs)
The initialization script 000_install_timescaledb.sh fails during container startup:
```
/usr/local/bin/docker-entrypoint.sh: sourcing /docker-entrypoint-initdb.d/000_install_timescaledb.sh
psql: error: connection to server at "timescale.railway.internal" (fd12:f996:cd45:0:1000:46:5f6c:f958), port 5432 failed: Connection refused
Is the server running on that host and accepting TCP/IP connections?
```
Issue: The initialization script tries to connect to timescale.railway.internal before the database is ready to accept connections, causing the TimescaleDB extension installation to fail.
## Reproduction Steps
1. Go to https://railway.app/template/timescale
2. Click "Deploy Now"
3. Select an existing project
4. Wait for deployment to complete
5. Copy the DATABASE_PUBLIC_URL from Variables tab
6. Try to connect from external application using the public URL
Expected: Connection succeeds and TimescaleDB extension is available
Actual: Connection fails with ECONNRESET or Connection terminated unexpectedly
## Connection Attempts (Node.js with pg driver)
```javascript
// Connection string from Railway Variables tab
const DATABASE_URL = 'postgresql://railway:PASSWORD@shuttle.proxy.rlwy.net:42884/railway';
// Error received
Error: read ECONNRESET
at TCP.onStreamRead (node:internal/stream_base_commons:216:20) {
errno: -54,
code: 'ECONNRESET',
syscall: 'read'
}
```
## Impact
- Template is unusable for production or development
- Users cannot connect to the database externally
- TimescaleDB extension is not installed, defeating the purpose of the template
- Multiple redeployments show the same issue (consistent bug)
## Suggested Fix
The initialization script 000_install_timescaledb.sh should:
1. Wait for PostgreSQL to be fully ready before attempting connections
2. Use Unix socket connections instead of TCP during initialization
3. Add proper retry logic with backoff
4. Or run the TimescaleDB extension installation as part of the Docker image build, not as an init script
## Workaround
Currently, users must:
1. Use TimescaleDB Cloud (external service) instead of Railway template
2. Or use plain PostgreSQL and manually install TimescaleDB (not possible on Railway's managed databases)
## Environment
- Railway Project: Multiple projects tested (consistent failure)
- Connection Method: External via TCP proxy (public networking)
- Client: Node.js 22.19.0 with pg driver v8.13.1
- Deployment Region: Amsterdam
## Request
Please fix the TimescaleDB template initialization script to properly install the TimescaleDB extension and ensure external connections work reliably.
2 Replies
2 months ago
Hey there! We've found the following might help you get unblocked faster:
If you find the answer from one of these, please let us know by solving the thread!
2 months ago
Hello,
That link you shared 404s, either way, the actual template deploys fine and accepts connections fine.
You also do not have the timescale template deployed, you have deployed your own custom Dockerfile for pgvector, so I'm not sure the relevance of the timescale template in this context.
Since this isn't an issue with the platform or the template, I'll open this up to the community to see if they are able to provide assistance.
Best,
Brody
Status changed to Awaiting User Response Railway • about 2 months ago