Can't attach volume to postgres db

a year ago

I want to use postgres 17 from ghcr.io/railwayapp-templates/postgres-ssl:17

I added a new service from Docker Image

attached a volume set it to /var/lib/postgresql/data and added the required env vars

something like

PGHOST=${{RAILWAY_PRIVATE_DOMAIN}}
PGPORT=5432
PGUSER=${{POSTGRES_USER}}
PGPASSWORD=${{POSTGRES_PASSWORD}}
PGDATABASE=railway
DATABASE_URL=postgresql://${{PGUSER}}:${{POSTGRES_PASSWORD}}@${{RAILWAY_PRIVATE_DOMAIN}}:5432/${{PGDATABASE}}

and I got this issue

initdb: error: directory "/var/lib/postgresql/data" exists but is not empty initdb: detail: It contains a lost+found directory, perhaps due to it being a mount point. initdb: hint: Using a mount point directly as the data directory is not recommended. Create a subdirectory under the mount point.

Solved

5 Replies

a year ago

Hello,

Perhaps you have forgot the PGDATA=/var/lib/postgresql/data/pgdata variable?

Best,

Brody


Status changed to Awaiting User Response Railway over 1 year ago


a year ago

Thanks, ok, now it builds, but I still can’t connect.

It shows as deployed successfully, in the Data tab, “Database Connection” keeps loading indefinitely, and when I try to use the public database URL, it also doesn’t connect.


Status changed to Awaiting Railway Response Railway over 1 year ago


a year ago

You likely have a few other misconfigurations, please link to the deployment in question.


Status changed to Awaiting User Response Railway over 1 year ago


a year ago

Per your new thread, the service link is -

https://railway.com/project/9acf2f18-e37c-4318-bd58-2cd8ccdd46c7/service/24ca2776-d752-47bc-a316-73642bb10a68/data

Please note, these UUIDs are in no way sensitive.


a year ago

All your variables are fine, but your service was missing a TCP Proxy domain, once I added that I redeployed your Database as to have it become accessible via the newly added Proxy.

You can now access the Data tab!


Railway
BOT

10 months ago

This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!

Status changed to Solved Railway 11 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...