Fixing Gateway 502 Error

I have a home server that I'm setting up with pterodactyl and nginx proxy manager and I've successfully setup the host for nginx proxy manager but when I go to the domain for the panel that I've set up I get a gateway error and I don't know what the problem is can anyone help?
75 Replies
dielolol
dielolol12mo ago
Anyone?
Chaika
Chaika12mo ago
Your nginx server is probably returning that if you're not using cloudflare tunnels. I would check your nginx logs first/make sure it can reach the backend you specified, I assume you're using it as a reverse proxy to pterodactyl?
dielolol
dielolol12mo ago
yes so I can access the panel outside of my home network Which logs should I check to make sure it reaches the backend? 2023/07/11 00:47:31 [emerg] 35678#35678: still could not bind() 2023/07/11 00:48:13 [emerg] 35834#35834: bind() to 0.0.0.0:80 failed (98: Unknown error) 2023/07/11 00:48:13 [emerg] 35834#35834: bind() to 0.0.0.0:80 failed (98: Unknown error) 2023/07/11 00:48:13 [emerg] 35834#35834: bind() to 0.0.0.0:80 failed (98: Unknown error) 2023/07/11 00:48:13 [emerg] 35834#35834: bind() to 0.0.0.0:80 failed (98: Unknown error) 2023/07/11 00:48:13 [emerg] 35834#35834: bind() to 0.0.0.0:80 failed (98: Unknown error) 2023/07/11 00:48:13 [emerg] 35834#35834: still could not bind() 2023/07/11 00:48:29 [emerg] 35891#35891: bind() to 0.0.0.0:80 failed (98: Unknown error) 2023/07/11 00:48:29 [emerg] 35891#35891: bind() to 0.0.0.0:80 failed (98: Unknown error) 2023/07/11 00:48:29 [emerg] 35891#35891: bind() to 0.0.0.0:80 failed (98: Unknown error) 2023/07/11 00:48:29 [emerg] 35891#35891: bind() to 0.0.0.0:80 failed (98: Unknown error) 2023/07/11 00:48:29 [emerg] 35891#35891: bind() to 0.0.0.0:80 failed (98: Unknown error) This is error.log.1
Chaika
Chaika12mo ago
nginx error logs, I have no experience using nginx proxy manager, so no clue where the default location for them with that is
dielolol
dielolol12mo ago
But I'm not sure if this was an error I had before or the same one Sorry I mean or this one
Chaika
Chaika12mo ago
looks like something is already using port 80, or something else is wrong with your config/setup
dielolol
dielolol12mo ago
Nginx Proxy manager uses port 80 so i dont think its that so Ill go over my config
Akama Aka
Akama Aka12mo ago
I had the same error not by using pterodactyl and also not with the same errors but I fixed it by changing the host to 0.0.0.0 (Which couldnt be secure if theres no Content-Security-Policy or so
dielolol
dielolol12mo ago
Wdym change the host to 0.0.0.0
Akama Aka
Akama Aka12mo ago
nvmd im dumb lol Just try another port I just the 49152 Ports upwards They are unassigned ports You just have to proxy them two times. one time with nginx and one time with cloudflare (if required)
dielolol
dielolol12mo ago
But isn’t nginx supposed to run on ports 80,81,443
Akama Aka
Akama Aka12mo ago
Yes nginx is running on 80 and your server like http or node server is running on the 49152 port It is a node web server right?
Akama Aka
Akama Aka12mo ago
That's my configuration but idk if it would work with pterodactyl
dielolol
dielolol12mo ago
hmm i have listen on 80 that may be the issue It's a personal server that I bought and is in my house
Akama Aka
Akama Aka12mo ago
If the pterodactly is listening on 80 and nginx also then yes
dielolol
dielolol12mo ago
but nginx is supposed to be listening on 80
Akama Aka
Akama Aka12mo ago
I dont really recommend it <:Panda_think:895298577872605184>
dielolol
dielolol12mo ago
my thing uses https so shouldnt i use 443 instead of 80
Akama Aka
Akama Aka12mo ago
Can make very much issues and cloudflare wouldnt help you then with their DDoS protection
dielolol
dielolol12mo ago
I already had it and before I only used it to host minecraft servers but now I want to set up a proxy and use it for other things
Akama Aka
Akama Aka12mo ago
Ah okay if its just for private use then its okay
dielolol
dielolol12mo ago
well# its not really but its not for large scale use If I have the cloudflare proxy setup shouldn't it already be DDOS protected?
Akama Aka
Akama Aka12mo ago
Even if the DDoS protection that Cloudflare issues wouldnt be usefull. Becaue if someone have access to your pterodactyl and uploads a "bot" or so with a code that sends him your private IP adress then you can say bye to your Internet Network
dielolol
dielolol12mo ago
Ah I see
Akama Aka
Akama Aka12mo ago
Yea, a (already termed) partned of mine had that issue and yea <:gx_heh:919545549865230368> It was kinda funny to watch him x3
dielolol
dielolol12mo ago
rip still want to get the proxy working though
Akama Aka
Akama Aka12mo ago
Yea. does it works now or not
dielolol
dielolol12mo ago
i dont think that was the issue theyre not listening on the same port
Akama Aka
Akama Aka12mo ago
Linux server or windows?
dielolol
dielolol12mo ago
dielolol
dielolol12mo ago
Linux server
Akama Aka
Akama Aka12mo ago
netstat -anpe | grep "80" | grep "LISTEN" try this And then prob. kill the process pid
dielolol
dielolol12mo ago
I need to install net tools one sec
Akama Aka
Akama Aka12mo ago
A life without net-tools is a hard life
dielolol
dielolol12mo ago
lol
dielolol
dielolol12mo ago
this is what comes up
dielolol
dielolol12mo ago
Do you want me to run it again in root?
Akama Aka
Akama Aka12mo ago
try these commands: sudo kill 83051 sudo kill 80800 Then the processes should be stopped and then try again
dielolol
dielolol12mo ago
thats weird It says no such process
Akama Aka
Akama Aka12mo ago
Try to restart the server
dielolol
dielolol12mo ago
its rebooting
Akama Aka
Akama Aka12mo ago
Prob. a ghost process. A process that is running but not really in use or accessible
dielolol
dielolol12mo ago
I see Also is a gateway error usually an issue with the ports?
Akama Aka
Akama Aka12mo ago
There can be a lot errors THe gateway error is issued by your Webserver aka nginx
dielolol
dielolol12mo ago
Im back in ok a lot of things have gone away
Akama Aka
Akama Aka12mo ago
nice
dielolol
dielolol12mo ago
dielolol
dielolol12mo ago
This could also be because the proxy isn't actually running yet
Akama Aka
Akama Aka12mo ago
looks okay
dielolol
dielolol12mo ago
Each time I reboot I need to manually start docker compose
Akama Aka
Akama Aka12mo ago
just try to start nginx and then pterodactyl All of that is running on docker?
dielolol
dielolol12mo ago
yes
Akama Aka
Akama Aka12mo ago
ohhh with docker I cant really help you
dielolol
dielolol12mo ago
ah
Akama Aka
Akama Aka12mo ago
Can you access pterodactyl from your computer via the ip
dielolol
dielolol12mo ago
Before I couldn't Because nginx was using port 80
Akama Aka
Akama Aka12mo ago
okay
dielolol
dielolol12mo ago
but the problem now is im not on my home network
Akama Aka
Akama Aka12mo ago
Are you using cloudflared or open ports?
dielolol
dielolol12mo ago
both wait you mean to access the server terminal for that I'm using open ports
Akama Aka
Akama Aka12mo ago
okay And it still not working right?
dielolol
dielolol12mo ago
one sec Again I can access nginx proxy manager but I'm still getting the gateway 502 error
Akama Aka
Akama Aka12mo ago
hm are there any errors you get?
dielolol
dielolol12mo ago
Is there a way I can test what part of the gateway is the problem on the terminal? no also I haven't completely finished the pterodactyl installation I am only onto the point where you install wings which is where I started seeing the problem
Akama Aka
Akama Aka12mo ago
strange
dielolol
dielolol12mo ago
https://www.youtube.com/watch?v=cbr8tddvAWw I've been using this video and it was all working until he opened his panel and it worked but mine didnt
lilciv
YouTube
Installing Pterodactyl Panel and Wings Behind Nginx Proxy Manager a...
**Reupload due to audio issues, sorry! Here we'll install the Pterodactyl Panel and Wings while securing the panel behind Nginx Proxy Manager and Cloudflare TIMESTAMPS 0:00 Intro and Prerequisites 2:30 Installing the Panel 6:05 Nginx Web Server Setup + Self-Signed Cert 9:25 Wings Setup 12:20 Nginx Proxy Manager Config 13:25 Adding the Wings No...
Akama Aka
Akama Aka12mo ago
Is it possible you get with him into contact via dc or so?
dielolol
dielolol12mo ago
I can try let me check There doesn't seem to be but it seems he's still actively reading comments so maybe I'll leave one
dielolol
dielolol12mo ago
I've left a comment but while doing that I read a section of the description that said this
dielolol
dielolol12mo ago
Could this possibly be what's been causing the issue?
Akama Aka
Akama Aka12mo ago
Yes You can create a origin Certificate
dielolol
dielolol12mo ago
I'm using a wildcard certificate
Akama Aka
Akama Aka12mo ago
ah okay
thefik
thefik12mo ago
Hi there, can I ask here too? I have same problem, sometimes my web send the notice 502 bad gateway, and i have check about error.log. Here is the error log from var/log/nginx/error.log: 2023/07/11 01:28:02 [error] 877351#877351: *491040 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: [IP XXX.XXX.XXX.XXX], server: mydomain.com, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "mydomain.com" anyone known that issue and how to fix this ?
Akama Aka
Akama Aka12mo ago
Use php8.+ Php7.4 isn't supported anymore as far I know