502 Bad Gateway PHP Storm but Interpreter and executable are set
Asked Answered
M

2

13
  • OS: Windows 7 - 64 bit
  • PHP: Standalone php.exe (PHP ver 5.5)
  • PHPStorm Version: 10.0.1

All the advice I see on getting past the 502 Gateway error in PhpStorm involve just making sure you've got your Interpreter and executable set. I'm using the standalone php.exe (http://windows.php.net/download#php-5.5 VC11 x86 Thread Safe (2015-Oct-01 01:25:56)) and have everything set to PHP 5.5

enter image description here

I am honestly confused why I'm still getting 502 errors.

I've run it multiple times, and it did run once (there were no changes from instances before or after) which I found profoundly odd, but only for one page load and it was not a repeatable occurrence.

Edit: Realized one difference when I opened up another project to compare to. The one time it did work, the right-click context menu looked different. The other project is debugging just fine. What makes the difference? What gives? Both projects are using the same interpreter.

... Also found that going back to the working project, the additional context menu item disappeared.

enter image description here

Edit 2: Still problem hunting... found that certain files will run right when I start PHPStorm and will have that context menu. Other files, however, won't at startup of PHPStorm. If I I try to debug a file without the addtional menu, the server will give 502 and then the "good" files won't have the extra menu. If I start with one that has the extra context menu first, it will run, although if I follow with one doesn't, the first file ceases working. I feel like I'm making "progress" but I am also getting more confused, especially since each of these times I try to run a different file, it asks me "[x] is a single-instance run configuration. Are you sure you want to stop the running one?" At which point I click "Stop and Rerun". I would figure that the ones giving 502 wouldn't have anything carrying over to the "good" files if things are stopped and rerun... but that appears to not be the case.

Edit 3: Wondered if maybe my interpreter setup might be bad, so I grabbed securewamp ( http://securewamp.org/en/ ), got the portable version, setup, used default setup with xdebug added on (this version: php_xdebug-2.4.0rc1-5.4-vc9.dll) and exact same problem.

I'm even at a loss of additional things to check.

Edit 4: Extra sure that it's something in PHPStorm now. One of the php files that wasn't ever working, I opened directly with the php.exe and it worked fine. It has to be some setting in phpstorm that I"m missing, or some broken function.

Edit 5: Following a trail of potential causes, tried the Run > Validate Debugger tool. Path and URL left to default (no reason to change them), and attempt to vlaidate results in "Please check that web path to validation script is correctly configured" and lists my directory.

Edit 6: Validation was only picking up on 127.0.0.1 because that's what SecureWAMP was running on. Turning off its server results in "failed to execute validation script: 'Connection refused: connect'.

Edit 7: As pointied out by LazyOne, my files in the first image are two different filetypes (php and html). I have done it with .php files on both sides, I just grabbed two of the files I was currently working in for the screenshot. Here's an example of one of the php's. enter image description here

Edit 8: I think I'm finally getting a solid pattern to when it works and when it doesn't. The context menu thing was a red herring. Ones without a submenu will work just fine when conditions are met.

  • A. A file that works (so far no pattern noticed yet for working files vs nonworking, in fact, one working and one nonworking file have the exact same code) must be selected.

  • B. Cannot, under any condition, "Stop and Rerun" a file as this will cause the file to hit bad gateway afterwards.

  • C. You can't open up a nonworking file. If you do, current server hangs and will continue to hang until a "stop and rerun" is run on a different file, after which all open files will get the bad gateway error. Opening a non-working file will cause currently working files to get the bad gateway error.

  • D. To get working files working again after C or D requires restarting system.

Edit 9: Was fiddling around with the validate debugger configuration tool, and finally got it to give me a different answer (feel silly for it, actually, just had to include the targeted directory in the url to the validation script even though I thought the site was hosting straight from that directory. Oh well. Anyway, had one error, not sure if it's the cause of my issues or not, but will research it. enter image description here

Edit 10: Adding to php.ini to address above error... xdebug.remote_enable=1

Edit 11: No real benefit seen from the added line.

Edit 12: Posting requested screenshot of browser enter image description here

Edit 13: Updates to the EAP (10.0.2) version of phpStorm. It appears the same result so far, although now at least the console is showing me the error too instead of just the webpage. Also tried running completely through SecureWAMP's apache server only to find out there's something blocking me from changing away from the default htdocs directory.

enter image description here

Monody answered 1/12, 2015 at 19:10 Comment(11)
Please post a screenshot of the error with URL visible in the browser.Monofilament
"Also found that going back to the working project, the additional context menu item disappeared." On left side you have PHP file .. and on the right - HTML. Why do you expect to see PHP commands in HTML files?Monofilament
@Monofilament It was just one of the files I was working in at the time, but it happens with the php files too, not just the html. I guess I should update so that's clear. Thanks.Monody
1) I'm glad that you have noticed my 2nd comment ... but what about comment #1. To difficult to do? 2) In any case: based on your last screenshot -- you are NOT using your WAMP web server (Apache) at all -- your are using PhpStorm's own simple built-in web server -- look at URL (remember my comment #1?) -- localhost:63342/PROJECT_NAME/ . So ... use your WAMP instead of built-in web server.Monofilament
I actually did forget about posting the image, sorry. (I started to, and then it started to hang, and then I wondered why it was hanging, and got completely distracted and then promptly forgot.) As for getting WAMP to work, I'll mess around with it and see if I can (apache isn't my strong point of the LAMP stack), but I wasn't really against using PHPstorm's built-in web server if it'd actually work.Monody
Please try 10.0.2 EAP build -- blog.jetbrains.com/phpstorm/2015/12/… . The issue with "502" is most likely due to some incompatible settings. Although in some cases it was actual built-in web server (at least youtrack.jetbrains.com/issue/WEB-17803 ticket says that it fixed some things). youtrack.jetbrains.com/issue/WEB-17317 is still open. Hard to say... but Apache will be a better choice anyway (keep in mind: built-in server has some restrictions on URLs unless manually configured).Monofilament
@Monofilament After some hacky workarounds, was finally was able to follow through on the using secureWAMP portable's apache instead of built-in server. Seems to be working well. Throw up that as an answer and I'll give you the correct.Monody
i am having the same error as you, except it's on a POST function not a GET.Hatch
The error I was not just on post functions, but pretty much anything that was having to interpret php for anything moderately complex. If it looks the same way for you, Omarrrio, I suggest changing interpreters.Monody
At a risk of sounding condescending, you wasted a lot of space here with information that has nothing to do with your problem. A lot of the details provided are not really important. Have you actually checked the logs to see what is causing the 502 error? @liljoshuJudgemade
Having same problem with nginx running in WSL environment on windows boxSallyanne
C
2

FWIW, I think this could be as simple as a timing-out problem.

My environment is very similar to the OPs, Win764, PhpStorm 10.0.4, PHP 5.5.27.

I have some F3 automated tests where I see the 502 Bad Gateway error frequently when I run the test code 'in the browser' using one of the little icons in the toolbar that floats to the upper right of my code. (See image below.)

For some of my test pages, the error seems to be first-time-only. Run once, fails, run again, works ok. Others seem to require 2 or 3 runs before they will work. But I have a couple that I've never seen work in the browser.

OTOH, if I right-click in the code window for any of these pages and debug, the code runs fine whether I let it run all the way through or walk it line by line.

Clearly, my tool setup is not wrong. Some tests can and do run from the browser every time.

What I THINK is happening is that the likely-to-fail tests execute fairly heavy db queries. And my php interpreter is aggressively timing out my requests when I run them in the browser.

But, each time a page runs and times out, one or more of its queries gets cached and the next time I run it, the page is faster. Eventually, for the ones that will run at all, enough of the db work is cached so the page can get in under the wire and finish before the time limit.

So that's my theory. What I haven't found is where and how to change the interpreter timeout interval. That is, the timeout interval when run from PhpStorm. I do already have

max_execution_time = 300

in my php.ini file and can see that it is set when I use phpinfo(). But I have to believe that it is getting overridden when the interpreter is run from PhpStorm.

Update -- possible fix: So even though my php.ini file has that max_execution_time setting, I tried looking at my php interpreter settings as described on this PhpStorm support page, steps 1 and 2. There my max_execution_time was 0. So, I added a setting for it using the UI on that page to be the same 300 I have in my php.ini. (Then I closed and re-opened PhpStorm -- a big of old-programmer paranoia.) So far, I've seen one bad gateway message on my 'worst' page but even it ran the second time. The others seem to all be running to completion. I'll do some watchful waiting and see if this 'fix' does me any good long term.

(And, before anyone feels compelled to point it out: Yes, caching queries is a terrible idea for automated tests. Gotta fix that -- but only after I figure out how to extend the interpreter timeout so my tests can succeed without caching.)

enter image description here

Conductor answered 6/10, 2016 at 18:24 Comment(0)
F
0

This does not directly answer the question, but might be useful to people stumbling on the 502 Bad Gateway error.

Another way of getting a 502 Bad Gateway error is when a php scripts emits too much errors/warnings/notices. I had a script that was generating thousands of notices because of uninitialised variables that would lead to the 502 Bad Gateway error.

One solution is to fix the php code generating those notices or alternatively, disabling notice reporting in the php.ini file by adding & ~E_NOTICE to the error_reporting setting.

For example

error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE
Foreword answered 13/9, 2018 at 12:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.