N8n deployed via Railway, update?

Hi All!

I have n8n deployed via docker on railway, what is the easiest way to upgrade without losing any of my flows or integrations?

Thanks in advance!

Hi @madhatter349 :wave: I just deployed via Railway to test - can you share your Dockerfile?

If you’re using this template, this will be the Dockerfile in the repo, which automatically is pulling latest:

FROM n8nio/n8n:latest

ARG PGPASSWORD
ARG PGHOST
ARG PGPORT
ARG PGDATABASE
ARG PGUSER

ENV DB_TYPE=postgresdb
ENV DB_POSTGRESDB_DATABASE=$PGDATABASE
ENV DB_POSTGRESDB_HOST=$PGHOST
ENV DB_POSTGRESDB_PORT=$PGPORT
ENV DB_POSTGRESDB_USER=$PGUSER
ENV DB_POSTGRESDB_PASSWORD=$PGPASSWORD

ARG ENCRYPTION_KEY

ENV N8N_ENCRYPTION_KEY=$ENCRYPTION_KEY

CMD ["n8n start"]

That means that you can always pull the latest version of n8n on redeployment without too much hassle or worry :+1:

1 Like

I did a simple redeploy, now I’m getting the following error “Error: command n8n not found”

I tried changing CMD [“n8n”, “start”] to CMD [“n8n start”] and it’s still not working.

I’m not too sure - but perhaps @Jon would have a better idea when he’s back on Monday?

tons of trial and error, tried every combo and tried searching github… FINALLY got it working.

“CMD [“start”]”

Thank you again for your help!

2 Likes

So glad to hear you got it working, and thank you for posting your solution! :tada:

I had this issue when I upgraded a long time ago. My credentials didnt transfer over, i get the folloing error:

“Problem loading credential Credentials could not be decrypted. The likely reason is that a different “encryptionKey” was used to encrypt the data.”

Hey @madhatter349,

So on Railway you can normally just hit reeploy in the Railway interface, There is a GitHub issue open on the Railway template where users were wondering the same thing: n8n update · Issue #1 · railwayapp-templates/n8n · GitHub

Assuming you have the encryption key environment key set and Postgres in use everything should be all good, The error around not being able to decrypt credentials tends to mean that N8N_ENCRYPTION_KEY has not been set or the value for it has been changed.

1 Like

Thank you! I manually just reentered all my credentials!

1 Like

Jumping on this thread, I am using this template to deploy n8n on Railway: https://railway.app/template/r2SNX_

I just logged on today to see that there’s a new update. I re-deployed as people suggested above but the update to 1.26.0 from 1.25.1 didn’t go through. I’m wondering if it’s not pulling the new docker image every time it redeploys? The source image is from Docker which I believe is the official one.

Do I have to log out and back in? Anyone have any ideas of what I could be doing wrong or missing?

1 Like

Hey @buildingthings,

It would depend on what the template is using for the version, the Railway templates are not official so it may be worth asking the maintainer what version tag they use.

I’ve been able to successfully upgrade my instance using the following code below for the Dockerfile.

I hope this helps:

FROM n8nio/n8n:latest

ARG PGPASSWORD
ARG PGHOST
ARG PGPORT
ARG PGDATABASE
ARG PGUSER

ARG USERNAME
ARG PASSWORD

ARG ENCRYPTIONKEY
ENV N8N_ENCRYPTION_KEY=$ENCRYPTIONKEY

ENV DB_TYPE=postgresdb
ENV DB_POSTGRESDB_DATABASE=$PGDATABASE
ENV DB_POSTGRESDB_HOST=$PGHOST
ENV DB_POSTGRESDB_PORT=$PGPORT
ENV DB_POSTGRESDB_USER=$PGUSER
ENV DB_POSTGRESDB_PASSWORD=$PGPASSWORD

ENV N8N_BASIC_AUTH_ACTIVE=true
ENV N8N_BASIC_AUTH_USER=$USERNAME
ENV N8N_BASIC_AUTH_PASSWORD=$PASSWORD

CMD [“start”]

Did you find a solution?
I’m also using the same, Releases · n8n-io/n8n · GitHub.
Is there any instruction on how to update on railway?
I’m no coder.

Thnx, this works.

Didn’t realize they weren’t official, thanks for the heads up!

@madhatter349 can you link which Railway template you’re using? And also where exactly does one input the code you pasted? I think the one I have is a bit more complex than I need cuz it has more than just a postgres DB so I might switch to the one that you’re using.

Thank you everyone!!

Simply re-deploying did work for me this time, but this is a few days later, so I assume that the maintainer has to keep pulling a new docker image for their template…

2 Likes