Welcome! Log In Create A New Profile

Advanced

Re: nginx reload fails with [emerg] host not found in upstream

Ruslan Ermilov
December 07, 2012 02:24AM
On Fri, Dec 07, 2012 at 01:22:50AM -0500, groknaut wrote:
> maybe this one's better:
>
> 12/07 06:19[root@proxy2-prod-ue1 ~]# cat gethostbyname.c
> #include <stdio.h>
> #include <netdb.h>
> #include <sys/socket.h>
> #include <arpa/inet.h>
> #include <netinet/in.h>
>
> int main(int argc, char *argv[])
> {
> if (argc < 2) {
> fprintf(stderr, "usage: %s hostname\n", argv[0]);
> return 1;
> }
>
> // skip 0 because that is the program name
> for (int i = 1; i < argc; ++i) {
>
> struct hostent *lh = gethostbyname( argv[i] );
>
> if (lh) {
> struct in_addr **addr_list;
> addr_list = (struct in_addr **) lh->h_addr_list;
>
> printf("%-14s %s\n",
> inet_ntoa( *addr_list[0] ),
> lh->h_name
> );
> }
> else {
> herror("gethostbyname");
> }
> }
>
> return 0;
> }
> 12/07 06:20[root@proxy2-prod-ue1 ~]# gcc -std=c99 gethostbyname.c -o
> gethostbyname.bin
> 12/07 06:20[root@proxy2-prod-ue1 ~]# ./gethostbyname.bin
> webapp02c.prod.romeovoid.com
> 10.51.23.17 webapp02c.prod.romeovoid.com
> 12/07 06:21[root@proxy2-prod-ue1 ~]# ./gethostbyname.bin
> webapp06c.prod.romeovoid.com
> 10.195.76.80 webapp06c.prod.romeovoid.com
>
>
> our DNS does work..

Like was already told, nginx internally does gethostbyname()
to resolve hostnames during configuration, so if a problem
disappears by moving the hostnames into /etc/hosts, I'd not
suspect nginx. (It does gethostbyname() twice due to how
it's currently coded, so it's expected.)

To emulate what nginx does internally when processing this
upstream, run it like this:

../gethostbyname.bin webapp02c webapp02c webapp06c webapp06c roapp02c roapp02c

WITHOUT hostnames in /etc/hosts. Do it several times in a row.

If that doesn't reveal the problem, do you have an ability
to recompile nginx from sources?

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

nginx reload fails with [emerg] host not found in upstream

groknaut December 06, 2012 09:37PM

Re: nginx reload fails with [emerg] host not found in upstream

姚伟斌 December 06, 2012 11:26PM

Re: nginx reload fails with [emerg] host not found in upstream

groknaut December 07, 2012 12:33AM

Re: nginx reload fails with [emerg] host not found in upstream

groknaut December 07, 2012 01:22AM

Re: nginx reload fails with [emerg] host not found in upstream

Ruslan Ermilov December 07, 2012 02:24AM

Re: nginx reload fails with [emerg] host not found in upstream

groknaut December 07, 2012 05:11PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 314
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready