Nginx-rtmp-module: nginx: [emerg] host not found in url

Created on 22 Feb 2016  Â·  30Comments  Â·  Source: arut/nginx-rtmp-module

Hi All,

I'm using ubuntu 14.04 with nginx and the rtmp module to transcode a 1080p to 720p and send it to twitch. I have it accepting the 1080p but when I add the push command to the .conf of nginx I get nginx: [emerg] host not found in url "live-1hr.twitch.tv/". I've used the same push commands in windows via nginx without any issues and if I use an IP it starts nginx so I'm presuming its something dns related?

Has anyone had this issue?

Thanks

Bob

Most helpful comment

I fixed it by adding a short delay once after a system reboot.

#/etc/systemd/system/nginx.service.d/override.conf 
[Service]
ExecStartPre=/bin/sleep 10
Restart=on-failure
RestartSec=5s

All 30 comments

You need to add _resolver 8.8.8.8;_ in your config.
By the way check your DNS config on Ubuntu.

Hi,

thanks for replying, i've tried adding the nameserve 8.8.8.8 8.8.8.4.4 to the resov.conf but this still doesn't allow me to start ngnix with a domain url for the push key.

Can you show full nginx config?

Hi,

Yep see below

user nobody;

worker_processes 1;

error_log logs/error.log;

error_log logs/error.log notice;

error_log logs/error.log info;

pid logs/nginx.pid;

events {
worker_connections 1024;
}

http {
allow all;
deny all;

access_log          logs/rtmp_access.log;
include             mime.types;
default_type        application/octet-stream;
sendfile            on;
keepalive_timeout   65;


server {
    listen      8081;
    server_name localhost;

    # rtmp stat
    location /stat {
        rtmp_stat all;
        rtmp_stat_stylesheet stat.xsl;
    }

    location /stat.xsl {
        # you can move stat.xsl to a different location
        root html;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}

}

rtmp {
server {
listen 1935;
chunk_size 4096;

        application live {
                live on;
                meta copy;
                exec ffmpeg -i rtmp://192.168.0.8/live -vcodec libx264 -#preset veryfast -x264opts nal-hrd=cbr:force-cfr=1:keyint=60 -b:v 3000k -#maxrate 3000k -bufsize 3000k -s 1280x720 -sws_flags spline -r 30 -acodec copy #-f flv push rtmp://192.168.0.17/live1;

       }

        application live1 {
                live on;
                meta copy;

push rtmp://live-1hr.twitch.tv/live_***************;
}
}
}

it complains that the push for live1 is the issue and its the url.

Try to add

resolver 8.8.8.8;

to rtmp block. It's nginx option too, not only resolv.conf :)

Propably server restart should help too, becuase it's clear - your nginx
can't resolve DNS name.

thanks for your help so far, i've treid that and it returns the following

nginx: [emerg] "resolver" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:52

the code is as follows

user nobody;

worker_processes 1;

error_log logs/error.log;

error_log logs/error.log notice;

error_log logs/error.log info;

pid logs/nginx.pid;

events {
worker_connections 1024;
}

http {
allow all;
deny all;

access_log          logs/rtmp_access.log;
include             mime.types;
default_type        application/octet-stream;
sendfile            on;
keepalive_timeout   65;


server {
    listen      8081;
    server_name localhost;

    # rtmp stat
    location /stat {
        rtmp_stat all;
        rtmp_stat_stylesheet stat.xsl;
    }

    location /stat.xsl {
        # you can move stat.xsl to a different location
        root html;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}

}

rtmp {
server {
listen 1935;
chunk_size 4096;
resolver 8.8.8.8;
application live {
live on;
meta copy;
exec ffmpeg -i rtmp://192.168.0.8/live -vcodec libx264 -preset veryfast -x264opts nal-hrd=cbr:force-cfr=1:keyint=60 -b:v 3000k -maxrate 3000k -bufsize 3000k -s 1280x720 -sws_flags spline -r 30 -acodec copy -f flv push rtmp://192.168.0.17/live1;

        }

        application live1 {
                live on;
                meta copy;

push rtmp://live-1hr.twitch.tv/live_***********;
}
}
}

Why do you need to push in back to nginx and push it again further?
Just tell ffmpeg to push it directly to twitch.

And nginx-rtmp not support resolver directive. So remove it from rtmp { } block.

I want use multiple push's to different rtmp servers in different resolutions / bitrates along with some using the record function, I've not not yet added them as I wanted to get the first working then scale it up.

I've removed the resolver directive but this was how it was originally and it still has the original issue.

$ host live-1hr.twitch.tv
Host live-1hr.twitch.tv not found: 3(NXDOMAIN)

There is no such host. Check you url.

Correct this was a typo when editing the config for here it's live-Lhr.twitch.tv I also ran it using Live-cdg.Twitch.TV and got the same response.

Can you ever do ping Live-cdg.Twitch.TV from machine with nginx?

And what version of nginx you are using?

Nginx and rtmp not start after reboot
Here is my config

May 1 15:59:57 nginx[991]: nginx: [emerg] host not found in url "a.rtmp.youtube.com/live2/xxxxxxxxxxxxxxxxx" in /etc/nginx/nginx.conf:81
May 1 15:59:57 nginx[991]: nginx: configuration file /etc/nginx/nginx.conf test failed

`

user www-data;
worker_processes auto;

error_log /var/log/nginx/rtmp_error.log debug;

error_log /var/log/nginx/rtmp_error.log;
pid /run/nginx.pid;

events {
worker_connections 1024;
# multi_accept on;
}

http {
allow all;
deny all;
#access_log /var/log/nginx/rtmp_access.log;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;

server {
listen 80;
server_name localhost;

    location / {
        root /var/www/html;
        index  index.html index.htm;
    }

    error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root /var/www/html;
    }

    location /stat {
        rtmp_stat all;
        rtmp_stat_stylesheet stat.xsl;
    }

    location /stat.xsl {
        root /var/www/html;
    }        
}    

}

rtmp {
server {
listen 1935;
chunk_size 8192;

#Restream
    application live {
                live on;
                meta copy;

                # Direct streaming:

        # GamingLive
                #push rtmp://broadcastEU.gaminglive.tv/push/sneaky4oe?secret=******************;

        # HitBox
                #push rtmp://live.hitbox.tv/push/sneaky4oe?key=************; #hitbox

        # Cybergame source
                #push rtmp://premium.cybergame.tv:1953/premium/sneaky4oe?key=*****************; #cybergame source

        # dailymotion (restream.io)
                #push rtmp://publish.dailymotion.com/publish-dm/*******?auth=****************************; #dailymotion

        # Twitch source 
              #  push rtmp://live-arn.justin.tv/app/live_xxxxxxxxxxxxx;

        # Twitch source 
                #push rtmp://live-arn.justin.tv/app/live_xxxxxxxxxxxxxx;
        # youtube source
                push rtmp://a.rtmp.youtube.com/live2/xxxxxxxxxxxxxxxxx;


  }
}

}`

I have this same issue when trying to push to youtube. On boot/restart, nginx will not start automatically. After the computer has booted up, if I run sudo service nginx restart, it will start fine, just not before having to login and do it manually.

i only get the [emerg] host not found in url with the youtube link. Other services (twitch, beam, hitbox,) work fine on reboot. I was thinking about setting up some kind of redirect with the hosts file or nginx to test if it would automatically start as a workaround.

I compile rtmp module into EasyEngine's nginx-custom build. https://github.com/EasyEngine/nginx-build

The same problem here.

same problem here, on boot, the service will fail after each reboot, on :

jun 08 19:46:36 luz nginx[1109]: nginx: [emerg] host not found in url "a.rtmp.youtube.com/live2/secretrtmpkey

so, after every reboot of the machine I have to

service nginx restart

and then my rtmp nginx will work

a few remarks :

  • I had that working on a mageia server with no problem
  • I have this problem since I migrated this service to ubuntu 16.04
  • my network setup is ok a.rtmp.youtube.com resolves :
    root@luz:~# host a.rtmp.youtube.com
    a.rtmp.youtube.com is an alias for bartmp.l.google.com.
    bartmp.l.google.com has address 173.194.136.204
    bartmp.l.google.com has IPv6 address 2800:3f0:4005:2::c
  • the complete push line in my nginx rtmp config is :
    push rtmp://a.rtmp.youtube.com/live2/secretkey;
  • it seems nginx is trying to resolve a.rtmp.youtube.com/live2/secretkey but it should try to resolve just the domain name ( a.rtmp.youtube.com resolves, not a.rtmp.youtube.com/live2/secretkey )
  • is it possible to tell nginx to NOT try to validate urls on start ?
  • that problem could also be related with the way systemd is configured on ubuntu since I didnt have this problem on a mageia linux server

same here

2018/09/15 06:27:26 [error] 20113#0: connect() to [2607:f8b0:4006:30::c]:1935 failed (101: Network is unreachable)
2018/09/15 06:27:26 [error] 20113#0: *34 relay: push failed name='1234' app='' playpath='' url='a.rtmp.youtube.com/live2/vcf3-ke8r-exxy-083t', client: 110.38.212.147, server: 0.0.0.0:1935
2018/09/15 06:27:27 [alert] 16406#0: worker process 20113 exited on signal 11 (core dumped)
# host a.rtmp.youtube.com
a.rtmp.youtube.com is an alias for bartmp.l.google.com.
bartmp.l.google.com has address 74.125.0.9
bartmp.l.google.com has IPv6 address 2607:f8b0:4006:31::c

You can try specyfing resolver with ipv6=off flag.

sob., 15.09.2018, 08:45 użytkownik Liu Lantao notifications@github.com
napisał:

2018/09/15 06:27:26 [error] 20113#0: connect() to [2607:f8b0:4006:30::c]:1935 failed (101: Network is unreachable)
2018/09/15 06:27:26 [error] 20113#0: *34 relay: push failed name='1234' app='' playpath='' url='a.rtmp.youtube.com/live2/vcf3-ke8r-exxy-083t', client: 110.38.212.147, server: 0.0.0.0:1935
2018/09/15 06:27:27 [alert] 16406#0: worker process 20113 exited on signal 11 (core dumped)

host a.rtmp.youtube.coma.rtmp.youtube.com is an alias for bartmp.l.google.com.bartmp.l.google.com has address 74.125.0.9bartmp.l.google.com has IPv6 address 2607:f8b0:4006:31::c

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/arut/nginx-rtmp-module/issues/766#issuecomment-421535965,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAbp9ufuC5L4t196TJufKahIMvGZtZZqks5ubKH1gaJpZM4HfQH_
.

@misiek08 I saw you have suggested many times in this thread, but
can you please give more information about how to set resolver in rtmp block?

As metioned in http://nginx.org/en/docs/http/ngx_http_core_module.html#resolver, resolver can only be set in
Context: http, server, location

# nginx -t
nginx: [emerg] "resolver" directive is not allowed here in /usr/local/nginx/conf/rtmp.conf:25
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed

I've also got the same problem here... any updates on how to fix this issue?

Well... as a workaround to fix this issue upon reboot I've added Restart and a RestartSec directives to nginx.service so it can recover from this specific error. Tested on CentOS7 with Nginx 1.15.8 and RTMP module.

Here is my nginx.service file

[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
Restart=on-failure
RestartSec=5s
PrivateTmp=true

[Install]
WantedBy=multi-user.target

I fixed it by adding a short delay once after a system reboot.

#/etc/systemd/system/nginx.service.d/override.conf 
[Service]
ExecStartPre=/bin/sleep 10
Restart=on-failure
RestartSec=5s

I fixed it by adding a short delay once after a system reboot.

#/etc/systemd/system/nginx.service.d/override.conf 
[Service]
ExecStartPre=/bin/sleep 10
Restart=on-failure
RestartSec=5s

Although I am a bit late to the party, I can confirm that this seems to do the trick for me as well, thanks for this Lax. I didn't compile it from source, but used the default package for Ubuntu 18.04 and had this exact same issue with the stream URL where it would error out when starting nginx on boot but a manual restart would then work.

I fixed it by adding a short delay once after a system reboot.

#/etc/systemd/system/nginx.service.d/override.conf 
[Service]
ExecStartPre=/bin/sleep 10
Restart=on-failure
RestartSec=5s

can you elaborate on this? Where is this being added?
"/etc/systemd/system/nginx.service.d/override.conf". ???
I don't have this file. I'm on a raspberry pi

Thank you in advance

can you elaborate on this? Where is this being added?
"/etc/systemd/system/nginx.service.d/override.conf". ???
I don't have this file. I'm on a raspberry pi

Thank you in advance

@calmasacow Just create the file at that location, maybe you need create the folder first.

can you elaborate on this? Where is this being added?
"/etc/systemd/system/nginx.service.d/override.conf". ???
I don't have this file. I'm on a raspberry pi
Thank you in advance

@calmasacow Just create the file at that location, maybe you need create the folder first.

doesn't seem to work on raspberry pi 4 raspian buster.

I'm not on RPI so that may be why it worked for me. I'm using nginx on a
macbook pro from 2008 running ubuntu LTS I believe. Only good use for the
machine lol. Also have an sql server on it too plus a twitch bot

Believe I am running the open source phantombot

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Mattyzero picture Mattyzero  Â·  6Comments

qhchen2 picture qhchen2  Â·  4Comments

DaveZheng picture DaveZheng  Â·  3Comments

ama-ableton picture ama-ableton  Â·  6Comments

WayneShao picture WayneShao  Â·  3Comments