I cloned an existing site and kept getting a ‘502 Bad Gateway’ error, which I had never gotten before when cloning. Nginx error log said this:
2017/08/22 18:49:44 [emerg] 425#0: bind() to 0.0.0.0:80 failed (98: Address already in use) 2017/08/22 18:49:44 [emerg] 425#0: still could not bind() 2017/08/22 18:49:47 [error] 274#0: *1 connect() to unix:/var/run/php-fpm.sock failed (111: Connection refused) while connecting to upstream, client: 172.17.0.1, server: ~^(.*)\.memory\.dev$, request: "GET / HTTP/1.0", upstream: "fastcgi://unix:/var/run/php-fpm.sock:", host: "memory.dev"
The site I was trying to create was using the URL ‘memory.dev’. I solved it by re-cloning and using ‘memorymeadows.dev’ instead. I’m not sure WHY this solved my issue, but I thought I would post this for future people-with-a-similar-problem to see how I solved it.
Glad you sorted it out!
It looks like nginx tried starting multiple times. Did you try restarting the site prior to cloning it?
I’m having this issue even with 2.1. I see a few other threads - is there any other solution? I’ve restarted everything possible.
Sometimes Docker won’t allocate ports correctly. Can you try going to Help » Restart Local’s Machine?
That didn’t do it. I even tried deleting that install completely and re-adding – it seems like having a .localhost URL suddenly is the problem?
Can you screenshot the error you’re seeing in your browser?
Then, can you provide the errors you’re seeing in the
logs folder for that site?
2017/11/06 20:05:04 [error] 24#0: 4 connect() to unix:/var/run/php-fpm.sock failed (111: Connection refused) while connecting to upstream, client: 172.17.0.1, server: ~^(.).npmclone.localhost$, request: “GET / HTTP/1.0”, upstream: “fastcgi://unix:/var/run/php-fpm.sock:”, host: “npmclone.localhost”
Thanks! Are you seeing anything in the PHP error log?
No - seems like it’s having issues writing to that
Nov 6, 2017, 12:06 PM PST - info: [environment/custom] [06-Nov-2017 20:06:27] ERROR: failed to open error_log (/var/log/php/5.3.29/php-fpm.log): No such file or directory (2)
[06-Nov-2017 20:06:27] ERROR: failed to post process the configuration
[06-Nov-2017 20:06:27] ERROR: FPM initialization failed Starting php-fpm failed
Can you try exporting the site and then re-importing it?
To export: right-click on the site and go to “Export”
To import: Drag and drop the resulting archive onto Local’s main window or Dock icon
Yeah, seems like that worked. I’ll have to test this more (if you want), but it seems like my install doesn’t like .localhost domains at all even when they’re in the hosts files.
When you export/re-import a site, are you supposed to delete the existing site after exporting and prior to re-importing? Or do you import over top of it?
If you’re having trouble with an existing site, I would delete the existing site only after you know the import succeeded.
So, the path may change after importing it.
I’m confused. How would the original site still exist to be deleted if you re-imported the same site? Did you mean that during the re-import you give it a different local domain name so that you have two separate installs (original, and imported one)? You can’t import a site that has the same domain as an existing site, correct? By the way, I’m the original creator of this thread and I solved my issue by cloning to a different domain, but when I saw your comment to Scott about export/re-import I was curious about that workflow for future debugging.
Yeah, when you re-import you’d select a new domain/path.
Clay, great support/responses. One clarification if you don’t mind. Is there any difference between exporting a site and re-importing it versus simply right-clicking on it and cloning it? Is one option better than another when someone encounters an error like the ones in this thread?
Cloning is very similar but it clones the Docker container as well.
Advantages of cloning:
- Brings over changes that you did to the container like installing something with
Disadvantages of cloning:
- Since it clones the container, it may bring over existing problems
- You don’t have the option to choose between Preferred/Custom when cloning. It locks you into what the origin site is using.
Note: same issue, even faster solution.
Changed PHP version from 7.1.x to 7.0.x, saved, started working.
Changed back to 7.1, saved, kept working…
“Reset Config” did not work, I tried that first. I had to actually change and save.
Following this thread to fix a 502 of my own I had an interesting adventure that may help someone…I exported, then imported as a new domain name…
…then the original started working…
I’ve been setting up Local for 2-3 days now, it’s nice, has some tweaks, but glad I learned about it at WordCamp Minneapolis.
Changing it to an old php and then changing it back worked for me. here is how to do it.