Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    New 502 Bad Gateway

    Scheduled Pinned Locked Moved 2.4 Development Snapshots
    281 Posts 67 Posters 199.4k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • BBcan177B
      BBcan177 Moderator
      last edited by

      As per jimp's suggestion, please try these two patched files which use a pfSense function called try_lock() as opposed to flock().

      Run the following commands to download the patched version of the two files from my Github Gist:

      fetch -o /usr/local/www/pfblockerng/www/index.php "https://gist.githubusercontent.com/BBcan177/9f9c8e62b166cee07ad16cd4ff59103c/raw"
      fetch -o /usr/local/pkg/pfblockerng/pfblockerng.inc "https://gist.githubusercontent.com/BBcan177/7ff15715be0f02afdbe0a00c676aedce/raw"
      

      Recommend a reboot after downloading the patches.

      You can review the Gist revisions here:

      index.php
          https://gist.github.com/BBcan177/9f9c8e62b166cee07ad16cd4ff59103c/revisions

      pfblockerng.inc
          https://gist.github.com/BBcan177/7ff15715be0f02afdbe0a00c676aedce/revisions

      Note: The try_lock() function calls might require increasing the timeout setting from the default setting of "5" (seconds)

      "Experience is something you don't get until just after you need it."

      Website: http://pfBlockerNG.com
      Twitter: @BBcan177  #pfBlockerNG
      Reddit: https://www.reddit.com/r/pfBlockerNG/new/

      1 Reply Last reply Reply Quote 0
      • BBcan177B
        BBcan177 Moderator
        last edited by

        Made a couple changes to the code… So if you have downloaded these files prior to this post, please re-download the same URLs above to get the new changes.... Thanks!

        "Experience is something you don't get until just after you need it."

        Website: http://pfBlockerNG.com
        Twitter: @BBcan177  #pfBlockerNG
        Reddit: https://www.reddit.com/r/pfBlockerNG/new/

        1 Reply Last reply Reply Quote 0
        • N
          ntct
          last edited by

          @BBcan177:

          Made a couple changes to the code… So if you have downloaded these files prior to this post, please re-download the same URLs above to get the new changes.... Thanks!

          Hi BBcan177

          Can you make a PR?

          1 Reply Last reply Reply Quote 0
          • BBcan177B
            BBcan177 Moderator
            last edited by

            Added some temp file removal to the patches. So please re-download this new code if you have downloaded these files prior to this post, please re-download the same URLs above to get the new changes…. Thanks!

            A reboot is recommended following these patches.

            Once the code has been tested, I will submit this as a PR.

            Please report back your feedback.

            Thanks!

            "Experience is something you don't get until just after you need it."

            Website: http://pfBlockerNG.com
            Twitter: @BBcan177  #pfBlockerNG
            Reddit: https://www.reddit.com/r/pfBlockerNG/new/

            1 Reply Last reply Reply Quote 0
            • H
              hdejongh
              last edited by

              @jimp:

              @hdejongh:

              hee Jim,

              https://pastebin.com/JVMQTWbY

              bad gateway 502 issue

              That looks like it was taken just after a reboot, not when the problem was happening. No sign of anything getting backed up in there.

              Hee Jim,

              im 99,99999% certain the issue was happening at that time.
              Ill do it again.

              this one is from an other firewall.
              it hangs on "sockstat" 15 minutes now so i think those wont come anymore.

              https://pastebin.com/Ek9R0qkh

              1 Reply Last reply Reply Quote 0
              • H
                ha11oga11o
                last edited by

                Here is more data with 502 err:

                https://pastebin.com/TqSBTKEK

                OpenVPN clients cannot connect also, which is mine major problem for now.

                hope will help.

                1 Reply Last reply Reply Quote 0
                • H
                  hdejongh
                  last edited by

                  @ha11oga11o:

                  Here is more data with 502 err:

                  https://pastebin.com/TqSBTKEK

                  OpenVPN clients cannot connect also, which is mine major problem for now.

                  hope will help.

                  it starts to become a major issue as well for us. Im about to restore backups..
                  All virtual firewall's that we upgraded have the same problem…
                  we have to reboot them multiple times per day to get it working, otherwise ipsec's and openvpn stop working.

                  1 Reply Last reply Reply Quote 0
                  • jimpJ
                    jimp Rebel Alliance Developer Netgate
                    last edited by

                    @hdejongh:

                    https://pastebin.com/Ek9R0qkh

                    it starts to become a major issue as well for us. Im about to restore backups..
                    All virtual firewall's that we upgraded have the same problem…
                    we have to reboot them multiple times per day to get it working, otherwise ipsec's and openvpn stop working.

                    If that is the output when you have the problem, then it's NOT this problem. No sign of pfBlocker or anything blocking PHP. Start a new thread, it's probably something already solved on 2.4.1 if it's a VM issue. Check the release notes.

                    Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                    Need help fast? Netgate Global Support!

                    Do not Chat/PM for help!

                    1 Reply Last reply Reply Quote 0
                    • jimpJ
                      jimp Rebel Alliance Developer Netgate
                      last edited by

                      @ha11oga11o:

                      Here is more data with 502 err:

                      https://pastebin.com/TqSBTKEK

                      OpenVPN clients cannot connect also, which is mine major problem for now.

                      That's the same as others here, pfBlocker DNSBL getting stuck waiting. Try to apply the fixed files from bbcan a few posts above yours.

                      Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                      Need help fast? Netgate Global Support!

                      Do not Chat/PM for help!

                      1 Reply Last reply Reply Quote 0
                      • B
                        beernutmark
                        last edited by

                        Just another "me too" post.  I have just applied the fixes above and will report back tomorrow morning if it doesn't lock up.  It has locked up within 24 hours ever since the 2.4 upgrade so hopefully a clean system in the morning will show success.

                        1 Reply Last reply Reply Quote 0
                        • H
                          hdejongh
                          last edited by

                          @jimp:

                          @hdejongh:

                          https://pastebin.com/Ek9R0qkh

                          it starts to become a major issue as well for us. Im about to restore backups..
                          All virtual firewall's that we upgraded have the same problem…
                          we have to reboot them multiple times per day to get it working, otherwise ipsec's and openvpn stop working.

                          If that is the output when you have the problem, then it's NOT this problem. No sign of pfBlocker or anything blocking PHP. Start a new thread, it's probably something already solved on 2.4.1 if it's a VM issue. Check the release notes.

                          ok, i will first upgrade to 2.4.1 and report back then!

                          1 Reply Last reply Reply Quote 0
                          • H
                            ha11oga11o
                            last edited by

                            @jimp:

                            @ha11oga11o:

                            Here is more data with 502 err:

                            https://pastebin.com/TqSBTKEK

                            OpenVPN clients cannot connect also, which is mine major problem for now.

                            That's the same as others here, pfBlocker DNSBL getting stuck waiting. Try to apply the fixed files from bbcan a few posts above yours.

                            I just did. Will revert with output if hangs.

                            Cheers!

                            1 Reply Last reply Reply Quote 0
                            • G
                              gsmornot
                              last edited by

                              I'm still learning. Can I just enter the two files from reply 165 into the command box via Diagnostics, Command? I am a GUI user.
                              I have not had any issues yet but following along to prevent any issues. I do use DNSBL and I am on 2.4.1. Was on 2.4 and the related RC's.

                              1 Reply Last reply Reply Quote 0
                              • H
                                ha11oga11o
                                last edited by

                                @gsmornot:

                                I'm still learning. Can I just enter the two files from reply 165 into the command box via Diagnostics, Command? I am a GUI user.
                                I have not had any issues yet but following along to prevent any issues. I do use DNSBL and I am on 2.4.1. Was on 2.4 and the related RC's.

                                Use putty as stated here, and when you log in choose shell and copy paste one row after another. Reboot unit and thats it. And use login "root" not "admin" as stated in video.

                                https://www.youtube.com/watch?v=krNuKDGEjvQ

                                Cheers!

                                1 Reply Last reply Reply Quote 0
                                • H
                                  hdejongh
                                  last edited by

                                  @jimp:

                                  @hdejongh:

                                  https://pastebin.com/Ek9R0qkh

                                  it starts to become a major issue as well for us. Im about to restore backups..
                                  All virtual firewall's that we upgraded have the same problem…
                                  we have to reboot them multiple times per day to get it working, otherwise ipsec's and openvpn stop working.

                                  If that is the output when you have the problem, then it's NOT this problem. No sign of pfBlocker or anything blocking PHP. Start a new thread, it's probably something already solved on 2.4.1 if it's a VM issue. Check the release notes.

                                  since upgrade tot 2.4.1 no problems yet!

                                  1 Reply Last reply Reply Quote 0
                                  • B
                                    beernutmark
                                    last edited by

                                    So far so good with the updated files.

                                    1 Reply Last reply Reply Quote 0
                                    • G
                                      gsmornot
                                      last edited by

                                      @ha11oga11o:

                                      @gsmornot:

                                      I'm still learning. Can I just enter the two files from reply 165 into the command box via Diagnostics, Command? I am a GUI user.
                                      I have not had any issues yet but following along to prevent any issues. I do use DNSBL and I am on 2.4.1. Was on 2.4 and the related RC's.

                                      Use putty as stated here, and when you log in choose shell and copy paste one row after another. Reboot unit and thats it. And use login "root" not "admin" as stated in video.

                                      https://www.youtube.com/watch?v=krNuKDGEjvQ

                                      Cheers!

                                      MAC user so I used terminal. Thank you for the point in the right direction, patched this morning after waking up to 502 Bad Gateway.

                                      1 Reply Last reply Reply Quote 0
                                      • F
                                        fraglord
                                        last edited by

                                        @BBcan177:

                                        As per jimp's suggestion, please try these two patched files which use a pfSense function called try_lock() as opposed to flock().

                                        Run the following commands to download the patched version of the two files from my Github Gist:

                                        fetch -o /usr/local/www/pfblockerng/www/index.php "https://gist.githubusercontent.com/BBcan177/9f9c8e62b166cee07ad16cd4ff59103c/raw"
                                        fetch -o /usr/local/pkg/pfblockerng/pfblockerng.inc "https://gist.githubusercontent.com/BBcan177/7ff15715be0f02afdbe0a00c676aedce/raw"
                                        

                                        Recommend a reboot after downloading the patches.

                                        You can review the Gist revisions here:

                                        index.php
                                            https://gist.github.com/BBcan177/9f9c8e62b166cee07ad16cd4ff59103c/revisions

                                        pfblockerng.inc
                                            https://gist.github.com/BBcan177/7ff15715be0f02afdbe0a00c676aedce/revisions

                                        Note: The try_lock() function calls might require increasing the timeout setting from the default setting of "5" (seconds)

                                        So Far running for more than 24 hrs without problems on pfsense 2.4.0 - I would say it looks pretty good.

                                        I will upgrade to pfsense 2.4.1 tonight.

                                        pfSense 2.4.0 (amd64) running on IGEL H710C | 1G RAM | 8G SSD | INTEL PRO/1000 PT Dual NIC

                                        1 Reply Last reply Reply Quote 0
                                        • J
                                          justsomeguy6575
                                          last edited by

                                          I haven't posted here but have been following the thread as I've had similar issues. After so many hours(less than half a day) pfsense gui and shell would become completely unresponsive even though clients still had internet access.

                                          Replacing the files "index.php" and "pfblockerng.inc" with the ones BBcan177 posted seems to have fixed the issue for me. I've been up for 41hrs now without a problem.

                                          1 Reply Last reply Reply Quote 0
                                          • B
                                            beernutmark
                                            last edited by

                                            Guess I spoke too soon. Just got the 502.  Also this seems to stop the firewall schedules from working as a schedule that was allowing access should have been stopped but access was still available.  Hopefully it's not affecting other aspects of the firewall security.

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.