Volume not retaining after deployment
dh-web-admin
PROOP

2 months ago

Hello, I have a volume attached to my web service and every time I upload something to it, it uploads successfully. (I ssh'd into the web service and created a file in the mounted directory) but every time my service is redeployed, my volume looses its files and contents.

$10 Bounty

3 Replies

2 months ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open brody 2 months ago


Railway
BOT

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!


darseen
HOBBYTop 5% Contributor

2 months ago

You are most likely writing files to the container's temporary disk rather than inside the persistent volume directory. When the container restarts, the temporary disk is wiped, but the volume remains untouched.

How to Fix It:

Check your Volume Mount Path

Click on your Service.

Go to the Settings tab.

Scroll down to the Volumes section.

Look at the Mount Path.

It might be set to /app/storage or /data for example.

Then Update Your Code

Your application is likely saving files to a relative path like ./uploads or just uploads/. This writes to the project root, which is temporary.

You must update your file upload logic to use the Absolute Path.


ilyassbreth
FREE

2 months ago

your app is probably writing files to the wrong path. here's what to check:

  1. find where your app writes files, look at your code, is it writing to something like ./uploads or /data or whatever?

  2. if your app uses a relative path (like ./uploads), your volume needs to be mounted at /app/uploads not just /uploads , railway puts your app in /app by default

  3. if your app uses an absolute path (like /data), mount your volume to that exact path

  4. quick test: ssh in, write a file directly to your mount path like echo "test" > /your-mount-path/test.txt, then redeploy and ssh back in , if the file is gone, your mount path is wrong

the most common mistake is mounting to /data when the app actually writes to ./data which means it needs /app/data

what path does your app write files to?


Loading...