502 nginx error

94 views
Skip to first unread message

Wangui njoka

unread,
Aug 6, 2019, 3:51:54 AM8/6/19
to Vagrant
Help .I am getting 502 error on browser after cloning a repo and doing vagrant up. i am fairly new to vagrant and i dont know whether the problem is with vagrant or the repo. the vagrant file is as below;

# -*- mode: ruby -*-
# vi: set ft=ruby :

PROJECT = "kala"
PROJECT_URL = "kala.example.com"

Vagrant.configure("2") do |config|
  config.vm.box = "bento/ubuntu-16.04"

  config.vm.network "forwarded_port", guest: 80, host: 9090

  config.vm.synced_folder "../", "/srv/" + PROJECT + "-app"

  config.vm.provider "virtualbox" do |vb|
    vb.name = PROJECT
    vb.customize ["modifyvm", :id, "--cableconnected1", "on"]
    vb.memory = "1024"
  end

  config.vm.provision "shell", path: "provision/vagrant.sh", args: [PROJECT, PROJECT_URL]
end

Dennis Chang

unread,
Aug 6, 2019, 9:02:09 AM8/6/19
to Vagrant
Try entering

127.0.0.1:9090 kala.example.com


Inside your /etc/hosts file and then try accessing http://kala.example.com again through your browser.

Wangui njoka

unread,
Aug 6, 2019, 10:55:13 AM8/6/19
to vagra...@googlegroups.com
Doing this did not help. I am still getting the same problem. Any other suggestions?

Cheers

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/94dedf0b-2665-42b7-b5bb-48ef7932204f%40googlegroups.com.

Dennis Chang

unread,
Aug 6, 2019, 11:42:20 AM8/6/19
to Vagrant
Instead of a browser can you use curl instead? (I'm presuming you are trying to access the VM, i.e. from the host).

So instead of the browser, run the command:


and provide the output please.

Dennis Chang

unread,
Aug 6, 2019, 11:45:36 AM8/6/19
to Vagrant
P.s. Reading this: https://www.lifewire.com/502-bad-gateway-error-explained-2622939

says a 502 is a gateway error. Which suggests to me that the VM contains a configuration which makes calls to a 3rd party.
That 3rd party appears to be unavailable and hence why you are getting the 502 error.

Since we won't know what your VM is doing, all we will be able to provide (in terms of suggestions) is to validate communication
with the nginx web server (a simple, standard, hello page) and you'll have to troubleshoot the rest.

Wangui njoka

unread,
Aug 6, 2019, 12:12:59 PM8/6/19
to vagra...@googlegroups.com
this returns 

curl -vvv http://kala.example.com
* Rebuilt URL to: http://kala.example.com/
* Could not resolve host: kala.example.com
* Closing connection 0
curl: (6) Could not resolve host: kala.example.com

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.

Dennis Chang

unread,
Aug 6, 2019, 9:51:05 PM8/6/19
to Vagrant
Try again with


Obviously the response to http://kala.example.com failed to resolve the hostname.
Remember that I suggested adding an entry to your host file, well that recommendation
should have resolve that issue.

Let me know how curl to http://127.0.0.1:9090 works out.


On Wednesday, 7 August 2019 00:12:59 UTC+8, Wangui njoka wrote:
this returns 

curl -vvv http://kala.example.com
* Rebuilt URL to: http://kala.example.com/
* Could not resolve host: kala.example.com
* Closing connection 0
curl: (6) Could not resolve host: kala.example.com

On Tue, Aug 6, 2019 at 6:42 PM Dennis Chang <dennis...@gmail.com> wrote:
Instead of a browser can you use curl instead? (I'm presuming you are trying to access the VM, i.e. from the host).

So instead of the browser, run the command:


and provide the output please.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagra...@googlegroups.com.

Wangui njoka

unread,
Aug 7, 2019, 9:46:14 AM8/7/19
to vagra...@googlegroups.com
* Rebuilt URL to: http://127.0.0.1:9090/
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 9090 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1:9090
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 502 Bad Gateway
< Server: nginx/1.10.3 (Ubuntu)
< Date: Wed, 07 Aug 2019 13:39:54 GMT
< Content-Type: text/html; charset=utf-8
< Content-Length: 182
< Connection: keep-alive
<
<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.10.3 (Ubuntu)</center>
</body>
</html>
* Connection #0 to host 127.0.0.1 left intact

To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/7c8b533f-f41d-498a-8909-0676445e6285%40googlegroups.com.

Dennis Chang

unread,
Aug 7, 2019, 9:42:31 PM8/7/19
to Vagrant
So what that tells us is that Nginx through your VM is responsive.
The only problem now is figuring out why Nginx is returning a 502 error.

What I would suggest you do is find the Nginx site configuration and replace
the configuration with the basic nginx default site page, see


and see if it returns a successful page.

I believe the problem now is with the pre-existing site configuration (the one you got from the repo).
You need to troubleshoot why it's returning a 502 error.
Reply all
Reply to author
Forward
0 new messages