502 Bad Gateway Error

agenticmarketer
PRO

3 months ago

I have an n8n instance installed but I keep receiving a crash error despite redeploying/restarting all four modules.

This is the link:
https://n8n.theagenticmarketer.com/

Solved$10 Bounty

13 Replies

Railway
BOT

3 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!


3 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 3 months ago


mikeyliow
HOBBY

3 months ago

have you added PORT to env?


3 months ago

Hey, were you able to access your n8n service using the public url which Railway generated/provided? mikeyliow also pointed out checking your port configuration as suggested in the documentation.


mikeyliow

have you added PORT to env?

agenticmarketer
PRO

3 months ago

Yes I have but the issue seems to be with postgres service.

Here's the log for it in case it helps?
Starting Container

PostgreSQL Database directory appears to contain a database; Skipping initialization

Jul 15 10:38:56

Jul 15 10:38:56

2025-07-15 05:08:56.142 UTC [2] LOG: starting PostgreSQL 16.3 (Debian 16.3-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit

Jul 15 10:38:56

2025-07-15 05:08:56.143 UTC [2] LOG: listening on IPv4 address "0.0.0.0", port 5432

Jul 15 10:38:56

2025-07-15 05:08:56.143 UTC [2] LOG: listening on IPv6 address "::", port 5432

Jul 15 10:38:56

2025-07-15 05:08:56.148 UTC [2] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"

Jul 15 10:38:56

2025-07-15 05:08:56.162 UTC [25] LOG: database system was interrupted while in recovery at 2025-07-15 03:24:35 UTC

Jul 15 10:38:56

2025-07-15 05:08:56.162 UTC [25] HINT: This probably means that some data is corrupted and you will have to use the last backup for recovery.

Jul 15 10:38:56

2025-07-15 05:08:56.213 UTC [25] LOG: database system was not properly shut down; automatic recovery in progress

Jul 15 10:38:56

2025-07-15 05:08:56.228 UTC [25] LOG: redo starts at 0/50AE9560

Jul 15 10:38:59

2025-07-15 05:08:59.077 UTC [25] LOG: redo done at 0/57FFFF08 system usage: CPU: user: 0.13 s, system: 0.19 s, elapsed: 2.84 s

Jul 15 10:38:59

2025-07-15 05:08:59.097 UTC [25] FATAL: could not write to file "pg_wal/xlogtemp.25": No space left on device

Jul 15 10:38:59

2025-07-15 05:08:59.102 UTC [2] LOG: startup process (PID 25) exited with exit code 1

Jul 15 10:38:59

2025-07-15 05:08:59.103 UTC [2] LOG: terminating any other active server processes

Jul 15 10:38:59

2025-07-15 05:08:59.104 UTC [2] LOG: shutting down due to startup process failure

Jul 15 10:38:59

2025-07-15 05:08:59.122 UTC [2] LOG: database system is shut down


uxuz

Hey, were you able to access your n8n service using the public url which Railway generated/provided? mikeyliow also pointed out checking your port configuration as suggested in the documentation.

agenticmarketer
PRO

3 months ago

Nope that doesn't work either


agenticmarketer

Nope that doesn't work either

3 months ago

Hey, since your database is the issue here, please make sure to restore a backup of your database if you have one.


uxuz

Hey, since your database is the issue here, please make sure to restore a backup of your database if you have one.

agenticmarketer
PRO

3 months ago

I haven’t got one since I’m on the hobby plan! Am I doomed?


agenticmarketer

I haven’t got one since I’m on the hobby plan! Am I doomed?

3 months ago

If you didn't make a backup yourself or used one of the community provided templates, then you are technically "doomed".


turborx
FREE

3 months ago

hi, your postgres container is out of disk space (no space left on device), which is causing the 502. you’ll need to free up or increase storage (or switch n8n’s DATABASE_URL to an external postgres) to fix it.


3 months ago

Apologies, looks like I have missed the "No space left on device" part of the logs, please try to grow your volume if it can be grown to 5GB in case you deployed the database on the trial plan.


turborx

hi, your postgres container is out of disk space (no space left on device), which is causing the 502. you’ll need to free up or increase storage (or switch n8n’s DATABASE_URL to an external postgres) to fix it.

agenticmarketer
PRO

3 months ago

Thanks for pointing me towards the right direction, increased the volume size and it works fine!

Attachments


newlefty
HOBBY

3 months ago

Hi, I'm having the same issue. My postgres disk space seems to have space as it's set to 5 GB and I've used up 3 GB. It keeps crashing every 15 mins or so. Could the disk space be misread and I'm really out of space?

Error: Could not establish database connection within the configured timeout of 20,000 ms. Please ensure the database is configured correctly and the server is reachable. You can increase the timeout by setting the 'DB_POSTGRESDB_CONNECTION_TIMEOUT' environment variable.

Jul 15 11:59:05

at DbConnection.init (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/@n8n+db@file+packages+@n8n+db_@sentry+node@8.52.1_ioredis@5.3.2_mongodb@6.11.0_@aws-sdk_f7bd9984f5e38971ca100f511ef3ee0b/node_modules/@n8n/db/src/connection/db-connection.ts:55:13)

Jul 15 11:59:05

at processTicksAndRejections (node:internal/process/task_queues:105:5)

Jul 15 11:59:05

at Start.init (/usr/local/lib/node_modules/n8n/src/commands/base-command.ts3)

Jul 15 11:59:05

at Start.init (/usr/local/lib/node_modules/n8n/src/commands/start.ts:202:3)

Jul 15 11:59:05

at CommandRegistry.execute (/usr/local/lib/node_modules/n8n/src/command-registry.ts:64:4)

Jul 15 11:59:05

at /usr/local/lib/node_modules/n8n/bin/n8n:63:2

Jul 15 11:59:05

Jul 15 11:59:05

Connection terminated due to connection timeout


newlefty

Hi, I'm having the same issue. My postgres disk space seems to have space as it's set to 5 GB and I've used up 3 GB. It keeps crashing every 15 mins or so. Could the disk space be misread and I'm really out of space? Error: Could not establish database connection within the configured timeout of 20,000 ms. Please ensure the database is configured correctly and the server is reachable. You can increase the timeout by setting the 'DB_POSTGRESDB_CONNECTION_TIMEOUT' environment variable.Jul 15 11:59:05at DbConnection.init (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/@n8n+db@file+packages+@n8n+db_@sentry+node@8.52.1_ioredis@5.3.2_mongodb@6.11.0_@aws-sdk_f7bd9984f5e38971ca100f511ef3ee0b/node_modules/@n8n/db/src/connection/db-connection.ts:55:13)Jul 15 11:59:05at processTicksAndRejections (node:internal/process/task_queues:105:5)Jul 15 11:59:05at Start.init (/usr/local/lib/node_modules/n8n/src/commands/base-command.ts3)Jul 15 11:59:05at Start.init (/usr/local/lib/node_modules/n8n/src/commands/start.ts:202:3)Jul 15 11:59:05at CommandRegistry.execute (/usr/local/lib/node_modules/n8n/src/command-registry.ts:64:4)Jul 15 11:59:05at /usr/local/lib/node_modules/n8n/bin/n8n:63:2Jul 15 11:59:05Jul 15 11:59:05Connection terminated due to connection timeout

3 months ago

Hey, please open your own dedicated help thread.


Status changed to Solved uxuz 3 months ago


502 Bad Gateway Error - Railway Help Station