2 months ago
Hi Railway team,
At first, my n8n workflows in “CCH n8n” project were running perfectly, but then they stopped because the Postgres volume reached almost 500 MB. I upgraded my Hobby plan to the Pro plan and increased the Postgres volume size to 50 GB. After resizing and redeploying, n8n could no longer run the workflows, and I received this error:
Connection Lost
You have a connection issue or the server is down.
n8n will reconnect automatically once the issue is resolved.
Problem running workflow
Lost connection to the server.
Attachments
Pinned Solution
2 months ago
looking at your logs, n8n is actually running fine now. the issue is your browser is caching the old failed connection
close all tabs with n8n open then open a new incognito/private window in your browser and go to https://primary-production-bbb0.up.railway.app
it should work now. if it does, then just clear your browser cache in your normal browser
if incognito still shows connection lost, add this one variable to Primary:
N8N_ALLOW_CONNECTIONS_FROM=*then redeploy and try again in incognito
your logs show "Editor is now accessible via: https://primary-production-bbb0.up.railway.app" which means n8n is running correctly. the connection lost is a browser-side websocket cache issue at this point
26 Replies
2 months ago
I suspect something went wrong after I upgraded the Postgres volume and redeployed my “CCH n8n” project. To verify, I created two brand-new n8n projects and started them immediately, but I still encountered the same issue:
Connection Lost
You have a connection issue or the server is down.
n8n will reconnect automatically once the issue is resolved.
Because even newly deployed projects cannot run n8n, I believe the problem may be on your end.
current one - This is my main n8n link (CCH n8n): primary-production-6ce9.up.railway.app
new - The second one (CCH Primary n8n): primary-production-0a95.up.railway.app
newest - third one (soothing-peace): https://primary-production-bbb0.up.railway.app/
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 noahd • 2 months ago
2 months ago
i think when you resized that postgres volume from 500mb to 50gb, the services got redeployed and some of your networking config needs updating. your services are trying to connect through public hosts instead of the private network and that's why you're getting the connection lost error
so go into your primary service and hit the variables tab. you need to change these redis ones:
QUEUE_BULL_REDIS_HOST = ${{Redis.REDISHOST_PRIVATE}}
QUEUE_BULL_REDIS_PORT = ${{Redis.REDISPORT_PRIVATE}}
and same thing for postgres:
DB_POSTGRESDB_HOST = ${{Postgres.POSTGRESHOST_PRIVATE}}
DB_POSTGRESDB_PORT = ${{Postgres.POSTGRESPORT_PRIVATE}}
the _PRIVATE part is super important because it makes everything talk through railway's internal network instead of going out to the internet and back
then you also gotta add these three (but use your actual domain obviously):
N8N_EDITOR_BASE_URL = https://primary-production-6ce9.up.railway.app
WEBHOOK_URL = https://primary-production-6ce9.up.railway.app
N8N_PROXY_HOPS = 1
2 months ago
oh and if you have a worker service do the same changes there too
if you're totally locked out and can't even get in, you can reset the user management through railway cli. don't worry your workflows are all safe in the database, this just removes the user accounts so you can make a new one:
npm install -g @railway/cli railway login railway link railway run n8n user-management:reset
then just make a new owner account and everything should be there
you'll need to do this for all three of your n8n instances btw. the new ones you created are probably failing for the same reason just needs the private network config
domehane
oh and if you have a worker service do the same changes there tooif you're totally locked out and can't even get in, you can reset the user management through railway cli. don't worry your workflows are all safe in the database, this just removes the user accounts so you can make a new one:npm install -g @railway/cli railway login railway link railway run n8n user-management:resetthen just make a new owner account and everything should be thereyou'll need to do this for all three of your n8n instances btw. the new ones you created are probably failing for the same reason just needs the private network config
2 months ago
I added the primary and worker variables as you recommended and redeployed, but it still doesn't work. I get an empty string. (I tried using my newly created one at the URL: primary-production-bbb0.up.railway.app.)
QUEUE_BULL_REDIS_HOST = ${{Redis.REDISHOST_PRIVATE}}
QUEUE_BULL_REDIS_PORT = ${{Redis.REDISPORT_PRIVATE}}
DB_POSTGRESDB_HOST = ${{Postgres.POSTGRESHOST_PRIVATE}}
DB_POSTGRESDB_PORT = ${{Postgres.POSTGRESPORT_PRIVATE}}
N8N_PROXY_HOPS = 1
N8N_EDITOR_BASE_URL = https://primary-production-bbb0.up.railway.app
WEBHOOK_URL = https://primary-production-bbb0.up.railway.app
Attachments
2 months ago
what your services are actually named and i can help you get the right variable format
domehane
what your services are actually named and i can help you get the right variable format
2 months ago
My services are named:
Primary (n8n web): https://primary-production-bbb0.up.railway.app/
Worker
Postgres plugin
Redis plugin
In Variables, when I set DB_POSTGRESDB_HOST = ${{Postgres.POSTGRESHOST_PRIVATE}} etc., it resolves to an empty string, so I think my plugin service names don’t match Postgres/Redis.
I tried to put exact values in variables instead of ${{...}}, it does not work as well
I did the same DB/Redis variables on:
- Primary (web)
- Worker
thank you very much for your help domehane
Attachments
2 months ago
ah okay i see them now in your screenshot the services are actually just called "Postgres" and "Redis" (with capital P and R)
so your variable references should work. but i notice thatyou're using the plugin versions which might not expose the _PRIVATE variables the same way
try this instead ,go directly to your Postgres service, click on it, then go to the Variables tab. you should see variables like:
POSTGRESHOST_PRIVATE
POSTGRESPORT_PRIVATE
POSTGRES_DB
POSTGRES_USER
POSTGRES_PASSWORD
copy those actual values and paste them directly into your Primary and Worker services like this:
DB_POSTGRESDB_HOST = postgres.railway.internal (or whatever the actual value is)
DB_POSTGRESDB_PORT = 5432
DB_POSTGRESDB_DATABASE = railway (or the actual database name)
DB_POSTGRESDB_USER = postgres (or actual username)
DB_POSTGRESDB_PASSWORD = (copy the actual password)
do the same thing for Redis go to the Redis service, check its variables tab, and copy:
REDISHOST_PRIVATE
REDISPORT_PRIVATE
then paste those values into Primary and Worker:
QUEUE_BULL_REDIS_HOST = redis.railway.internal (or whatever it shows)
QUEUE_BULL_REDIS_PORT = 6379
basically skip the reference syntax entirely and just use the raw values. the plugin services sometimes have different variable naming than regular services
also make sure you have these in Primary: N8N_EDITOR_BASE_URL = https://primary-production-bbb0.up.railway.app WEBHOOK_URL = https://primary-production-bbb0.up.railway.app N8N_PROXY_HOPS = 1 PORT = 5678
then redeploy both Primary and Worker
domehane
ah okay i see them now in your screenshot the services are actually just called "Postgres" and "Redis" (with capital P and R)so your variable references should work. but i notice thatyou're using the plugin versions which might not expose the _PRIVATE variables the same waytry this instead ,go directly to your Postgres service, click on it, then go to the Variables tab. you should see variables like:POSTGRESHOST_PRIVATEPOSTGRESPORT_PRIVATEPOSTGRES_DBPOSTGRES_USERPOSTGRES_PASSWORDcopy those actual values and paste them directly into your Primary and Worker services like this:DB_POSTGRESDB_HOST = postgres.railway.internal (or whatever the actual value is)DB_POSTGRESDB_PORT = 5432DB_POSTGRESDB_DATABASE = railway (or the actual database name)DB_POSTGRESDB_USER = postgres (or actual username)DB_POSTGRESDB_PASSWORD = (copy the actual password)do the same thing for Redis go to the Redis service, check its variables tab, and copy:REDISHOST_PRIVATEREDISPORT_PRIVATEthen paste those values into Primary and Worker:QUEUE_BULL_REDIS_HOST = redis.railway.internal (or whatever it shows)QUEUE_BULL_REDIS_PORT = 6379basically skip the reference syntax entirely and just use the raw values. the plugin services sometimes have different variable naming than regular servicesalso make sure you have these in Primary: N8N_EDITOR_BASE_URL = https://primary-production-bbb0.up.railway.app WEBHOOK_URL = https://primary-production-bbb0.up.railway.app N8N_PROXY_HOPS = 1 PORT = 5678then redeploy both Primary and Worker
2 months ago
I followed your recommendation and added those variables as literal values instead of using reference syntax, but it still doesn't work. I still get "Connection Lost" in my n8n flows.
There are no POSTGRESHOST_PRIVATE or POSTGRESPORT_PRIVATE variables from my Postgres service, nor REDISHOST_PRIVATE or REDISPORT_PRIVATE from my Redis service (see the attached screenshots). I deployed these services originally from Railway n8n setups/templates
From the logs I got 'Invalid Origin'
I tried added these variables to Primary
N8N_HOST=primary-production-bbb0.up.railway.app
N8N_PROTOCOL=https
N8N_PORT=5678
PORT=5678
N8N_PROXY_HOPS=1
N8N_TRUST_PROXY=true
N8N_EDITOR_BASE_URL=https://primary-production-bbb0.up.railway.app
WEBHOOK_URL=https://primary-production-bbb0.up.railway.app
N8N_PUSH_BACKEND=sse
and added these to Worker
N8N_HOST=primary-production-bbb0.up.railway.app
N8N_PROTOCOL=https
N8N_PROXY_HOPS=1
N8N_TRUST_PROXY=true
N8N_EDITOR_BASE_URL=https://primary-production-bbb0.up.railway.app
WEBHOOK_URL=https://primary-production-bbb0.up.railway.app
The errors of Invalid Origin show on both projects, my current usage and newly created project.
2 months ago
remove N8N_PORT and use the correct postgres variable names (PGHOST not POSTGRESHOST). railway's postgres plugin exposes PG* variables not POSTGRES* variables
2 months ago
for Primary service:
remove these variables completely:
N8N_PORT (delete this one, it's breaking things)
keep or add these:
PORT=5678
N8N_HOST=primary-production-bbb0.up.railway.app
N8N_PROTOCOL=https
N8N_EDITOR_BASE_URL=https://primary-production-bbb0.up.railway.app
WEBHOOK_URL=https://primary-production-bbb0.up.railway.app
N8N_PROXY_HOPS=1
N8N_SECURE_COOKIE=true
N8N_PUSH_BACKEND=ssefor the database connections, since your postgres/redis plugins don't show the _PRIVATE variables, use the variable reference syntax with the regular host variables:
DB_POSTGRESDB_HOST=${{Postgres.PGHOST}}
DB_POSTGRESDB_PORT=${{Postgres.PGPORT}}
DB_POSTGRESDB_DATABASE=${{Postgres.PGDATABASE}}
DB_POSTGRESDB_USER=${{Postgres.PGUSER}}
DB_POSTGRESDB_PASSWORD=${{Postgres.PGPASSWORD}}
DB_TYPE=postgresdb
QUEUE_BULL_REDIS_HOST=${{Redis.REDISHOST}}
QUEUE_BULL_REDIS_PORT=${{Redis.REDISPORT}}
QUEUE_BULL_REDIS_PASSWORD=${{Redis.REDISPASSWORD}}note the exact capitalization it's PGHOST not POSTGRESHOST
for Worker service:
PORT=5678
N8N_PROTOCOL=https
EXECUTIONS_MODE=queue
DB_POSTGRESDB_HOST=${{Postgres.PGHOST}}
DB_POSTGRESDB_PORT=${{Postgres.PGPORT}}
DB_POSTGRESDB_DATABASE=${{Postgres.PGDATABASE}}
DB_POSTGRESDB_USER=${{Postgres.PGUSER}}
DB_POSTGRESDB_PASSWORD=${{Postgres.PGPASSWORD}}
DB_TYPE=postgresdb
QUEUE_BULL_REDIS_HOST=${{Redis.REDISHOST}}
QUEUE_BULL_REDIS_PORT=${{Redis.REDISPORT}}
QUEUE_BULL_REDIS_PASSWORD=${{Redis.REDISPASSWORD}}2 months ago
redeploy both services after making these changes
2 months ago
any updates ?
domehane
redeploy both services after making these changes
2 months ago
I have deleted N8N_PORT and followed your guidance, but I am still getting the same errors and connection lost.
Attachments
2 months ago
ok li will try with you for the last time , so please follow those steps as described
2 months ago
step 1 clear out everything go to your Primary service variables tab and delete ALL these variables:
N8N_PORT
N8N_LISTEN_ADDRESS
NODE_OPTIONS
N8N_RUNNERS_ENABLED
anything else n8n related except what i list below
2 months ago
step 2 set only these variables for Primary
PORT=5678
N8N_EDITOR_BASE_URL=https://primary-production-bbb0.up.railway.app
WEBHOOK_URL=https://primary-production-bbb0.up.railway.app
N8N_HOST=primary-production-bbb0.up.railway.app
N8N_PROTOCOL=https
N8N_PROXY_HOPS=1
DB_TYPE=postgresdb
DB_POSTGRESDB_HOST=${{Postgres.PGHOST}}
DB_POSTGRESDB_PORT=${{Postgres.PGPORT}}
DB_POSTGRESDB_DATABASE=${{Postgres.PGDATABASE}}
DB_POSTGRESDB_USER=${{Postgres.PGUSER}}
DB_POSTGRESDB_PASSWORD=${{Postgres.PGPASSWORD}}
QUEUE_BULL_REDIS_HOST=${{Redis.REDISHOST}}
QUEUE_BULL_REDIS_PORT=${{Redis.REDISPORT}}
QUEUE_BULL_REDIS_PASSWORD=${{Redis.REDISPASSWORD}}
EXECUTIONS_MODE=regular2 months ago
step 3 click redeploy
2 months ago
after it restarts, go to the deployments logs. look for lines that show n8n starting up if you see that, it means the variables are being read correctly
2 months ago
if not working send me the first 20,30 lines of the deployment logs right when it starts up
2 months ago
still not working, there is no "Restart" button in my Settings, I need to redeploy to update env variables
my n8n still have "connection lost" but it seems like I don't have Invalid origin anymore
Attachments
2 months ago
Thank you very much for your help and contribution, Domehane.
I may need to consider migrating to another hosting/service provider if my n8n cannot run smoothly on Railway. The "Connection Lost" issues occur both in my current projects and newly created projects (Railway n8n templates). If the Railway team cannot investigate and provide guidance to resolve these issues, I will have to explore other options, as this directly affects our operations.
2 months ago
i think this is a good news , in logs there is no more invalid origin error which means the url config is working. the "connection lost" is now a websocket/sse issue so
add this one variable to Primary:
N8N_PUSH_BACKEND=websocketand remove this if you have it:
N8N_PUSH_BACKEND=sserailway's proxy works better with websocket than sse for n8n. redeploy after adding it
domehane
i think this is a good news , in logs there is no more invalid origin error which means the url config is working. the "connection lost" is now a websocket/sse issue soadd this one variable to Primary:N8N_PUSH_BACKEND=websocketand remove this if you have it:N8N_PUSH_BACKEND=sserailway's proxy works better with websocket than sse for n8n. redeploy after adding it
2 months ago
Thank you domehone, I added N8N_PUSH_BACKEND=websocket to my Primary, got all the services redeployed but still does not work
Attachments
2 months ago
looking at your logs, n8n is actually running fine now. the issue is your browser is caching the old failed connection
close all tabs with n8n open then open a new incognito/private window in your browser and go to https://primary-production-bbb0.up.railway.app
it should work now. if it does, then just clear your browser cache in your normal browser
if incognito still shows connection lost, add this one variable to Primary:
N8N_ALLOW_CONNECTIONS_FROM=*then redeploy and try again in incognito
your logs show "Editor is now accessible via: https://primary-production-bbb0.up.railway.app" which means n8n is running correctly. the connection lost is a browser-side websocket cache issue at this point
2 months ago
it works ?
domehane
it works ?
2 months ago
Thank you very much, Domehane.
You are my savior. After following your guidance and opening it in a different browser, the "Connection Lost" issue no longer occurs. I am now able to save and run the workflows.
Status changed to Solved brody • 2 months ago
