title: Coturn stun server returned an error with code=701
body: <p>I have my own server with ubuntu 19.</p>
  
  <p>NOTE: I need a stun/turn server for a video chat web application. It works already if both devices are in the same network.</p>
  
  <p>I have successfully installed and configured coturn. I can successfully start the turnserver by running:
  <code>turnserver</code> or <code>nohup turnserver &amp;</code> in the terminal.</p>
  
  <p>NOTE: I have an <code>SSH</code> connection to my server.</p>
  
  <p>I also ensured that the necessary ports are open and checked them with <code>netstat -tulpn</code>.</p>
  
  <p>I have been also restarting coturn a few times while testing <code>sudo service coturn restart</code>.</p>
  
  <p>I use these configurations in the <code>turnserver.conf</code>:</p>
  
  <pre><code># Also tried 80
  listening-port=3478
  # Also tried 443
  tls-listening-port=5349
  listening-ip=&lt;MY-IP4&gt;
  listening-ip=&lt;MY-IP6&gt;
  relay-ip=&lt;MY-IP4&gt;
  external-ip=&lt;MY-IP4&gt;
  oauth
  user=root:&lt;password&gt;
  userdb=/var/lib/turn/turndb
  no-stdout-log
  </code></pre>
  
  <p>This is my iceServers config in js, which I believe should work (I have done TONS of other combinations).</p>
  
  <pre><code>var pcConfig = {
    'iceServers': [
      {
        'urls': 'stun:&lt;MY-IP4&gt;:80'
      },
      {
        'urls': 'turn:&lt;MY-IP4&gt;:80',
        'credential': '&lt;PASSWORD&gt;',
        'username': 'root'
      }
    ]
  };
  </code></pre>
  
  <p>I have done TONS of different stun/turn server combinations, e.g.:</p>
  
  <ul>
  <li><p>I used google's stun servers: stun.l.google.com:19302, stun2.l.google.com:19302 etc.</p></li>
  <li><p>I tried ports 3478 and 5349 (of course after restarting coturn)</p></li>
  <li><p>I tried to use credentials for the stun server, but I am sure it does not need them</p></li>
  <li><p>I tried to use IP6 address</p></li>
  </ul>
  
  <p>I have also been doing tests live on my webproject and also here:
  <a href="https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/" rel="noreferrer">https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/</a></p>
  
  <p>Basically the testing URL above always gives me:</p>
  
  <pre><code>Note: errors from onicecandidateerror above are not neccessarily fatal. For example an IPv6 DNS lookup may fail but relay candidates can still be gathered via IPv4.
  The server stun:&lt;MY-IP4&gt;:80 returned an error with code=701:
  STUN server address is incompatible.
  The server stun:&lt;MY-IP4&gt;:80 returned an error with code=701:
  STUN server address is incompatible.
  </code></pre>
  
  <p>It does not matter whether I use google's stun server or my own, the error is the same.</p>
  
  <p>My webproject and the video chat WORKS great if I use the same network, but I believe stun and turn servers are not used in the same network. </p>
  
  <p>Also while I updated my JS file I always deleted cache, so the new JS file was used. So that was also not an issue.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>This combination does not give an error, only:</p>
  
  <pre><code>Note: errors from onicecandidateerror above are not 
  neccessarily fatal. For example an IPv6 DNS 
  lookup may fail but relay candidates can still be gathered via IPv4.
  </code></pre>
  
  <p>Tested on <a href="https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/" rel="noreferrer">https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/</a></p>
  
  <pre><code>{
    'urls': 'stun:&lt;MY-IP6&gt;:80'
  },
  {
    'urls': 'turn:&lt;MY-IP4&gt;:80',
    'credential': '&lt;PASSWORD&gt;',
    'username': 'root'
  }
  </code></pre>
  
  <p>I simply used IP6 for the stun and IP4 for turn.
  Video chat in different network still does not work, nowhere other errors to find.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Noticed today that <a href="https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/" rel="noreferrer">https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/</a>
  does not work. I had no errors on firefox. BUT you can enter some nonesense there and it will also show no errors... </p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I have also added now valid certificates:</p>
  
  <pre><code>cert=/usr/local/etc/turn.pem                                                                                    
  pkey=/usr/local/etc/turn.key.pem
  </code></pre>
  
  <p>Seems to work. I restarted coturn and status tells me that everything is running without issues. </p>
  
  <p>Video chat still does not work in different networks.</p>