I would like to make a local unencrypted service that listens on available via SSL on both IPv4 and IPv6 on port 8001.

Unfortunately, stunnel configuration

accept = 8001
connect = 8000

binds only on IPv4, as I have checked via netstat and ncat:

~$ sudo netstat -an|grep 800 | grep LISTEN
tcp        0      0  *               LISTEN     
tcp        0      0  *               LISTEN

~$ ncat --ssl -v ::1 8001
Ncat: Version 6.46 ( http://nmap.org/ncat )
Ncat: Connection refused.

However, the port seems to be blocked also on IPv6. When I add

[Server IPv6]
accept = :::8001
connect = 8000

stunnel will not start, since the port is blocked:

[ ] Service [pyload Web] (FD=7) bound to
[!] Error binding service [pyload Web IPv6] to :::8001
[!] bind: Address already in use (98)

I have tried both orders for the respective sections in my stunnel config file. I am using version 5.02 from the Ubuntu Utopic repository. Any ideas?

  • show netstat -an | grep 8000 | grep LISTEN for a first configuration fragment.
    – drookie
    Feb 11, 2015 at 10:22
  • I have included the outputs in my question now.
    – mcandril
    Feb 11, 2015 at 12:51
  • what error message exaclty are you getting ?
    – drookie
    Feb 11, 2015 at 12:55
  • Added it to my question :)
    – mcandril
    Feb 11, 2015 at 13:04

2 Answers 2


Looks like I found an answer myself. Why doesn't this IPv6 listen directive also accept IPv4? states from the nginx doc that

In Linux by default any IPv6 TCP socket also accepts IPv4 traffic 
... the runtime parameter: net.ipv6.bindv6only which has the value 0 by default. 

So I used ONLY the [Server IPv6]. This gives only a tcp6 entry in netstat, but I am also able to connect via IPv4.

This also explains the behaviour, since stunnel implicitly tries to bin to the IPv4 port in the v6 section. I am unsure if my solution is good practice and if one can rely in the net.ipv6 default. I think there should be a ipv6only option in stunnel, like there is for nginx and socat.


In order to get both ipv4 and ipv6 to work at the same time on my ubuntu 16.04 machine (a Linode) I had to configure stunnel to bind to all ipv6 addresses, like this:

accept = :::443

Specifying a particular ipv6 address would bind successfully to that one address, but would not allow ipv4 requests to go through.

accept = ipv6.sqlite.org:443  ;# Does not accept IPv4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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