404 error when deploying

orangejon
HOBBY

3 months ago

I'm having an issue with my Rails 8 application deployment on Railway. When I try to access the application either via my custom domain or the Railway-generated domain (with or without SSL), I'm getting a "404 - The train has not arrived at the station" error message.

What's strange is that I don't see any HTTP requests showing up in the HTTP logs section of the Railway dashboard, which makes me think the requests aren't even reaching my application container.

Here are the details of my setup:

1. The application is a Ruby on Rails 8.01 app with PostgreSQL database

2. I encountered a Thor::MalformattedArgumentError related to the PORT environment variable, which I resolved by hardcoding the port to 3000 in my Dockerfile and Procfile

3. My app properly references DATABASE_URL in config/database.yml

4. The deployment seems to complete successfully according to the logs

5. The healthcheck appears to fail repeatedly (the log shows "Attempt failed with service unavailable"), so presumably it also receives the same error that I do when trying to access it

  1. PostgreSQL is configured as a separate service in Railway, from the standard template (as well as a service worker for SolidQueue)

Could this be related to a networking/routing problem? Something related to how Railway handles ports?

I'd appreciate any help on how to get this working!

-------

Deployment ID: 8f915fad-970a-4ce2-8f36-90177470e6f4

Deploy logs:

Starting Container

Mar 19 23:18:46

=> Booting Puma

Mar 19 23:18:46

=> Rails 8.0.1 application starting in development

Mar 19 23:18:46

=> Run bin/rails server --help for more startup options

Mar 19 23:18:51

WARNING: Could not start PostgreSQL. Database operations may fail.

Mar 19 23:18:53

Puma starting in single mode...

Mar 19 23:18:53

* Puma version: 6.6.0 ("Return to Forever")

Mar 19 23:18:53

* Ruby version: ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux]

Mar 19 23:18:53

* Min threads: 5

Mar 19 23:18:53

* Max threads: 5

Mar 19 23:18:53

* Environment: development

Mar 19 23:18:53

* PID: 1

Mar 19 23:18:53

* Listening on http://0.0.0.0:3000

Mar 19 23:18:53

Use Ctrl-C to stop

Solved

4 Replies

orangejon
HOBBY

3 months ago

startCommand = "bundle exec rails server -b 0.0.0.0 -p 3000"

If I run this locally on my machine, it starts, it just gives an "ActiveRecord::ConnectionNotEstablished" error page because of course I don't have a separate PostreSQL instance like on Railway. But it doesn't give any other errors.


3 months ago

Hello?

Have you checked your deploy logs? -

PG::ConnectionBad: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory (PG::ConnectionBad)

You need to connect to Postgres via its URL, not via a socket.


Status changed to Awaiting User Response railway[bot] 4 months ago


orangejon
HOBBY

3 months ago

Yeah, I fixed that. I have fixed the original issue now by specifying the port of the server in the networking settings of the Rails instance. Thanks!


Status changed to Awaiting Railway Response railway[bot] 4 months ago


3 months ago

Awsome!


Status changed to Awaiting User Response railway[bot] 4 months ago


Status changed to Solved brody 4 months ago


404 error when deploying - Railway Help Station