PHP: 504 Time-out
It's my first time deploying an PHP app, as I'm trying to pass an interview. They sent me a custom, legacy PHP framework and gave me a task which was successfully finished. I was happy till the moment I've realized that my deployment is not working :peepoexit:
Error: 504 Gateway Time-out | nginx/1.24.0
I suppose the problem lays in Port usage, but I can not find anything online on how to utilize $PORT.
Solution:Jump to solution
Fix:
1. Delete deployment from your project
2. Click add domain again, and this time nginx's php-fpm will prompt you for a port, and suggest port of your PHP app 🪄...21 Replies
Project ID:
e3e3275b-dd08-457b-83d6-d3c46e4fddd6
e3e3275b-dd08-457b-83d6-d3c46e4fddd6
I've tried to co create custom
nginx.template.conf
, but again nothing worked:
this has nothing to do with PORT
this is an issue with the code or configuration
Hi Brody. Glad you are here.
Any idea on how to debug this issue then if I can't see any errors in logs?
Locally everything works just fine (as always :hmm:).
are you on the v2 runtime? check your service settings
Yeah. Should I change to legacy?
I've updated the project to PHP 8.3.8.
yeah try legacy, you may get more logs from legacy since there is a bug with the v2 runtime where some logs dont show up
@Brody
I've tried to push one fix with
V2
, and it was building for over 10 minutes. Removed it, switched to Legacy
, there are only Nginx
related logs again :notstonks:then that means you arent logging the error
Well, no, I'm trying to log at least the start of the application mate
It's a very very simple application, nothing can be broken here, literally
its going to be very hard to chase down bugs without proper logging
All I'm trying to say, is, I would see the log if the configuration was right and by going to "https://betterstack-project-production-7fea.up.railway.app/" I would be accessing the application. But I'm not. And I just want to learn what should I even do.
add proper error handling and logging
ok.
@Brody
I've pushed error-handling update, featuring logging and error handling for the root route.
Nothing works, but I've got a "type" of log:
2024/06/24 16:02:26 [error] 55#55: *9 open() "/app/"" failed (2: No such file or directory), client: 192.168.63.241, server: localhost, request: "GET /%22 HTTP/1.1", host: "betterstack-project-production-7fea.up.railway.app"
It's trying to access app dir, and for some reason it does not even exist?@aleks php time
@Brody :blob_help:
It works on another platform.
that doesn't mean you don't have something missconfigured on this platform
I'm sure you've seen the meme "it works on my machine"
:hmm: well
any help apart from being sure that my code is bad tho? :MattCool:
I've commented out all of my code, simply returning "hello world" and nothing works either. Project specific settings are all default too.
Solution
Fix:
1. Delete deployment from your project
2. Click add domain again, and this time nginx's php-fpm will prompt you for a port, and suggest port of your PHP app 🪄thanks @Brody for believing in me 🙏🏻