Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Having server with CentOS and Plesk. Installed nginx right how it's discribed here: But now if i go to I'm getting

502 Bad Gateway

This error seems to be because Apache doesn't respond to NginX. BUT if I get to i see the correct page. So Apache seems to run fine at 8080-th port. And in that instruction Apache supposed to be at 8080-th! So this seems to be correct.

Also in

/var/www/vhosts/ I see:

  server {
  listen      80;
  server_name ;
  error_log /var/www/vhosts/ warn;

  location / {
    include  /etc/nginx/proxy.conf;

  location ~*/w3tc/* {
    include  /etc/nginx/proxy.conf;

  location ~* ^.+\.(jpg|jpeg|gif|png|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|wav|bmp|rtf|js|ico|swf)$ {
    root /var/www/vhosts/;
    expires 7d;

So... as I understand this, it directs nginx to to get the page from Apache.

Let's see the error log vi /var/www/vhosts/

2012/02/07 07:35:29 [error] 11758#0: *1 could not be resolved (110: Operation timed out), client: 89.112.11.xx, server:, request: "GET / HTTP/1.1", host: ""

Okay, it can't resolve this domain. Buy why? I even added

to the /etc/hosts file

If I try


it downloads the page. But why NginX can't resolve this host?

What's wrong? Where to look for the reason?

share|improve this question

closed as off-topic by HopelessN00b Feb 25 '15 at 8:53

  • This question does not appear to be about server, networking, or related infrastructure administration within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 0 down vote accepted

Seems that your system can't resolve this domain. nginx doesn't use /etc/hosts file to resolve domains. Check that /etc/resolv.conf contains correct nameservers. I suggest you to explicitly specify IP address or localhost:

location / {
    proxy_pass http://localhost:8080;

Or you can specify better resolver for nginx, that knows this domain, instead of resolvers from /etc/resolv.conf:


You can check if resolver knows the domain:

# dig @
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.