Unable to connect to IPv4 IRC server when bindhost is IPv6 & IPv4 #9

Closed
opened 2026-10-05 03:53:05 +02:00 by adam · 40 comments
Owner

Hi

I have bindhost which has an IPv6 and an IPv4 address, when I connect to an IPv6 IRC server ZNC connects fine, when I connect to an IPv4 server I get

[08:43] <_status> Attempting to connect to [1.2.3.4 6667] ...
[08:43] <_status> Cannot connect to IRC (Invalid argument). Retrying...

If I run ZNC in debug mode I see the following

User [user] is connecting to [1.2.3.4 6667] ...
Csocket.cpp:880 Connect Failed. ERRNO [22] FD [6]
IRC::user == SockError(22 Invalid argument)

Is this something that can be fixed?

Work around for now is to create a bindhost which is the IPv4 address of which ZNC will use to connect from.

Regards

Hi I have bindhost which has an IPv6 and an IPv4 address, when I connect to an IPv6 IRC server ZNC connects fine, when I connect to an IPv4 server I get [08:43] <_status> Attempting to connect to [1.2.3.4 6667] ... [08:43] <_status> Cannot connect to IRC (Invalid argument). Retrying... If I run ZNC in debug mode I see the following User [user] is connecting to [1.2.3.4 6667] ... Csocket.cpp:880 Connect Failed. ERRNO [22] FD [6] IRC::user == SockError(22 Invalid argument) Is this something that can be fixed? Work around for now is to create a bindhost which is the IPv4 address of which ZNC will use to connect from. Regards <!-- github-sync-id:749596 -->
adam closed this issue 2026-10-05 03:53:05 +02:00
Author
Owner

ZNC first resolves your bind host. If that results in an IPv6 address, it will use IPv6. If it gets an IPv4 address, it will use IPv4 for the connection to the target.
So this results in ZNC trying to connect to a IPv4 address with an IPv6 bindhost which isn't going to work.

ZNC first resolves your bind host. If that results in an IPv6 address, it will use IPv6. If it gets an IPv4 address, it will use IPv4 for the connection to the target. So this results in ZNC trying to connect to a IPv4 address with an IPv6 bindhost which isn't going to work. <!-- github-comment-id:979687 -->
Author
Owner

It would make sense to fix csocket.
It should support bindhosts with both ipv4 and ipv6 ips, and in case of ipvX-only remote host choose appropriate family.

It would make sense to fix csocket. It should support bindhosts with both ipv4 and ipv6 ips, and in case of ipvX-only remote host choose appropriate family. <!-- github-comment-id:979839 -->
Author
Owner

psychon, I did gather that, my point is more that it should see that the bindhost has 2 IP address, one is IPv6 and the is IPv4 and it should use the in the same address family as the server is connecting to.
When I first came across this I spent ages looking at it, since the error message is "Invalid argument" I thought I had entered in something wrong or something was odd was going on with server.

This problem is going show up more are more as the IPv4 address space runs out and people go for dual stacked IPv6 and IPv4 systems and put the both IPv6 and IPv4 address to one domain name or bindhost in the case of ZNC.

This should be fixed and done properly instead of just closing the issue.

psychon, I did gather that, my point is more that it should see that the bindhost has 2 IP address, one is IPv6 and the is IPv4 and it should use the in the same address family as the server is connecting to. When I first came across this I spent ages looking at it, since the error message is "Invalid argument" I thought I had entered in something wrong or something was odd was going on with server. This problem is going show up more are more as the IPv4 address space runs out and people go for dual stacked IPv6 and IPv4 systems and put the both IPv6 and IPv4 address to one domain name or bindhost in the case of ZNC. This should be fixed and done properly instead of just closing the issue. <!-- github-comment-id:992199 -->
Author
Owner

Is anyone working on this? I could perhaps do it.

Is anyone working on this? I could perhaps do it. <!-- github-comment-id:1356278 -->
Author
Owner

dxtr, welcome! ;)

dxtr, welcome! ;) <!-- github-comment-id:1356749 -->
Author
Owner

Hehe. Thanks.
I looked over CSocket earlier and I noticed that some things could be improved. So do you have someone working on this or should I go ahead? I've got too much time on my hands :D

Hehe. Thanks. I looked over CSocket earlier and I noticed that some things could be improved. So do you have someone working on this or should I go ahead? I've got too much time on my hands :D <!-- github-comment-id:1356794 -->
Author
Owner

Feel free to work on it. Imaginos (can be found on IRC, timezone is sth like GMT-9) is the Csocket author / maintainer, we just pull his version of Csocket.cc and Csocket.h

Feel free to work on it. Imaginos (can be found on IRC, timezone is sth like GMT-9) is the Csocket author / maintainer, we just pull his version of Csocket.cc and Csocket.h <!-- github-comment-id:1357388 -->
Author
Owner

#47 is a duplicate of this. (Colloquy module wants to send a push to colloquy.mobi (only has an A record), but bindhost is a v6 address)

#47 is a duplicate of this. (Colloquy module wants to send a push to colloquy.mobi (only has an A record), but bindhost is a v6 address) <!-- github-comment-id:2040507 -->
Author
Owner

This should be fixed since 717d0596e3. If you still have this issue please re-open.

This should be fixed since 717d0596e3723a77d0158a633ec3c37f1d6f02d9. If you still have this issue please re-open. <!-- github-comment-id:3697430 -->
Author
Owner

This bug is still exists for me with version:

<*status> ZNC 1.4 - http://znc.in
<*status> IPv6: yes, SSL: yes, DNS: threads

I wanted to connect to irc.nerv.fi +6697 - but with BindHost to my host it was wrote:
<*status> Cannot connect to IRC (Invalid argument). Retrying...
Removing the BindHost entry will immediately allow me to log in.

How can I get the full error message without debug mode? The "Invalid argument" is nothing... - this message should be fixed too!

This bug is still exists for me with version: ``` <*status> ZNC 1.4 - http://znc.in <*status> IPv6: yes, SSL: yes, DNS: threads ``` I wanted to connect to irc.nerv.fi +6697 - but with BindHost to my host it was wrote: `<*status> Cannot connect to IRC (Invalid argument). Retrying...` Removing the BindHost entry will immediately allow me to log in. How can I get the full error message without debug mode? The "Invalid argument" is nothing... - this message should be fixed too! <!-- github-comment-id:59619120 -->
Author
Owner

So what was your bindhost? "localhost"?
irc.nerv.fi resolves to both v4 and v6.

2014-10-18 16:46 GMT+01:00 B. Roland notifications@github.com:

This bug is still exists for me with version:

<_status> ZNC 1.4 - http://znc.in
<_status> IPv6: yes, SSL: yes, DNS: threads

I wanted to connect to irc.nerv.fi +6697 - but with BindHost to my host
it was wrote:
<*status> Cannot connect to IRC (Invalid argument). Retrying...
Removing the BindHost entry will immediately allow me to log in.

How can I get the full error message without debug mode? The "Invalid
argument" is nothing... - this message should be fixed too!

—
Reply to this email directly or view it on GitHub
https://github.com/znc/znc/issues/37#issuecomment-59619120.

So what was your bindhost? "localhost"? irc.nerv.fi resolves to both v4 and v6. 2014-10-18 16:46 GMT+01:00 B. Roland notifications@github.com: > This bug is still exists for me with version: > > <_status> ZNC 1.4 - http://znc.in > <_status> IPv6: yes, SSL: yes, DNS: threads > > I wanted to connect to irc.nerv.fi +6697 - but with BindHost to my host > it was wrote: > <*status> Cannot connect to IRC (Invalid argument). Retrying... > Removing the BindHost entry will immediately allow me to log in. > > How can I get the full error message without debug mode? The "Invalid > argument" is nothing... - this message should be fixed too! > > — > Reply to this email directly or view it on GitHub > https://github.com/znc/znc/issues/37#issuecomment-59619120. <!-- github-comment-id:59620592 -->
Author
Owner

my host was it: "server1.ennet.sk" - now it is using my IP (no BindHost).

my host was it: "server1.ennet.sk" - now it is using my IP (no BindHost). <!-- github-comment-id:59620631 -->
Author
Owner

On your machine (where ZNC runs) it resolves to 94.229.34.11?

2014-10-18 17:30 GMT+01:00 B. Roland notifications@github.com:

my host was it: "server1.ennet.sk" - now it is using my IP.

—
Reply to this email directly or view it on GitHub
https://github.com/znc/znc/issues/37#issuecomment-59620631.

On your machine (where ZNC runs) it resolves to 94.229.34.11? 2014-10-18 17:30 GMT+01:00 B. Roland notifications@github.com: > my host was it: "server1.ennet.sk" - now it is using my IP. > > — > Reply to this email directly or view it on GitHub > https://github.com/znc/znc/issues/37#issuecomment-59620631. <!-- github-comment-id:59620744 -->
Author
Owner

Yep:

$ dig server1.ennet.sk

; <<>> DiG 9.7.3 <<>> server1.ennet.sk
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47680
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 0

;; QUESTION SECTION:
;server1.ennet.sk.              IN      A

;; ANSWER SECTION:
server1.ennet.sk.       43200   IN      A       94.229.34.11

;; AUTHORITY SECTION:
ennet.sk.               43200   IN      NS      ns2.ennet.sk.
ennet.sk.               43200   IN      NS      ns1.ennet.sk.

;; Query time: 4 msec
;; SERVER: 94.229.32.36#53(94.229.32.36)
;; WHEN: Sat Oct 18 18:33:21 2014
;; MSG SIZE  rcvd: 86
Yep: ``` $ dig server1.ennet.sk ; <<>> DiG 9.7.3 <<>> server1.ennet.sk ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47680 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 0 ;; QUESTION SECTION: ;server1.ennet.sk. IN A ;; ANSWER SECTION: server1.ennet.sk. 43200 IN A 94.229.34.11 ;; AUTHORITY SECTION: ennet.sk. 43200 IN NS ns2.ennet.sk. ennet.sk. 43200 IN NS ns1.ennet.sk. ;; Query time: 4 msec ;; SERVER: 94.229.32.36#53(94.229.32.36) ;; WHEN: Sat Oct 18 18:33:21 2014 ;; MSG SIZE rcvd: 86 ``` <!-- github-comment-id:59620782 -->
Author
Owner

May you run znc -D and paste relevant lines from it (with the bindhost set)?

2014-10-18 17:35 GMT+01:00 B. Roland notifications@github.com:

Yep:

$ dig server1.ennet.sk

; <<>> DiG 9.7.3 <<>> server1.ennet.sk
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47680
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 0

;; QUESTION SECTION:
;server1.ennet.sk. IN A

;; ANSWER SECTION:server1.ennet.sk. 43200 IN A 94.229.34.11

;; AUTHORITY SECTION:ennet.sk. 43200 IN NS ns2.ennet.sk.ennet.sk. 43200 IN NS ns1.ennet.sk.

;; Query time: 4 msec
;; SERVER: 94.229.32.36#53(94.229.32.36)
;; WHEN: Sat Oct 18 18:33:21 2014
;; MSG SIZE rcvd: 86

—
Reply to this email directly or view it on GitHub
https://github.com/znc/znc/issues/37#issuecomment-59620782.

May you run znc -D and paste relevant lines from it (with the bindhost set)? 2014-10-18 17:35 GMT+01:00 B. Roland notifications@github.com: > Yep: > > $ dig server1.ennet.sk > > ; <<>> DiG 9.7.3 <<>> server1.ennet.sk > ;; global options: +cmd > ;; Got answer: > ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47680 > ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 0 > > ;; QUESTION SECTION: > ;server1.ennet.sk. IN A > > ;; ANSWER SECTION:server1.ennet.sk. 43200 IN A 94.229.34.11 > > ;; AUTHORITY SECTION:ennet.sk. 43200 IN NS ns2.ennet.sk.ennet.sk. 43200 IN NS ns1.ennet.sk. > > ;; Query time: 4 msec > ;; SERVER: 94.229.32.36#53(94.229.32.36) > ;; WHEN: Sat Oct 18 18:33:21 2014 > ;; MSG SIZE rcvd: 86 > > — > Reply to this email directly or view it on GitHub > https://github.com/znc/znc/issues/37#issuecomment-59620782. <!-- github-comment-id:59620960 -->
Author
Owner

I've found these line, while the global BindHost was "server1.ennet.sk"

[2014-10-18 19:14:55.856971] TDNS: IRC::antivirtel::NervFi, connecting to [83.145.200.33] using bindhost [127.0.1.1]
[2014-10-18 19:14:55.857051] src/Csocket.cpp:1137 Connect Failed. ERRNO [22] FD [5]
[2014-10-18 19:14:55.857083] IRC::antivirtel::NervFi == SockError(22 Invalid argument)
I've found these line, while the global BindHost was "server1.ennet.sk" ``` [2014-10-18 19:14:55.856971] TDNS: IRC::antivirtel::NervFi, connecting to [83.145.200.33] using bindhost [127.0.1.1] [2014-10-18 19:14:55.857051] src/Csocket.cpp:1137 Connect Failed. ERRNO [22] FD [5] [2014-10-18 19:14:55.857083] IRC::antivirtel::NervFi == SockError(22 Invalid argument) ``` <!-- github-comment-id:59622235 -->
Author
Owner

2014-10-18 18:17 GMT+01:00 B. Roland notifications@github.com:

using bindhost [127.0.1.1]

Fix your /etc/resolv.conf, you can't connect to external server using
localhost as bindhost.

2014-10-18 18:17 GMT+01:00 B. Roland notifications@github.com: > using bindhost [127.0.1.1] Fix your /etc/resolv.conf, you can't connect to external server using localhost as bindhost. <!-- github-comment-id:59622430 -->
Author
Owner

I am having save problem

Disconnected from IRC (Server address is IPv6-only, but bindhost is IPv4-only). Reconnecting...

How I fix this ?

I am having save problem Disconnected from IRC (Server address is IPv6-only, but bindhost is IPv4-only). Reconnecting... How I fix this ? <!-- github-comment-id:267100904 -->
Author
Owner

@fahadmehar try clearing your bindhost, /msg *status setuserbindhost or /msg *status setbindhost. If that doesn't help, give more details such as /msg *status version and output from znc -D showing the error.

Related: https://github.com/znc/znc/issues/241 as thanks to it people set 0.0.0.0 as bindhost.

@fahadmehar try clearing your bindhost, `/msg *status setuserbindhost` or `/msg *status setbindhost`. If that doesn't help, give more details such as `/msg *status version` and output from `znc -D` showing the error. Related: https://github.com/znc/znc/issues/241 as thanks to it people set 0.0.0.0 as bindhost. <!-- github-comment-id:267290756 -->
Author
Owner

It's /msg *status clearbindhost. 0.0.0.0 shouldn't be needed anymore.

It's `/msg *status clearbindhost`. 0.0.0.0 shouldn't be needed anymore. <!-- github-comment-id:267299370 -->
Author
Owner

This is my Ver
<*status> ZNC 1.6.4 - http://znc.in
<*status> IPv6: yes, SSL: yes, DNS: threads, charset: no

This is my Ver <*status> ZNC 1.6.4 - http://znc.in <*status> IPv6: yes, SSL: yes, DNS: threads, charset: no <!-- github-comment-id:267368917 -->
Author
Owner

Please I really want to set VHost,

Please I really want to set VHost, <!-- github-comment-id:267369145 -->
Author
Owner

How I fix this '?

<*status> Disconnected from IRC (Server address is IPv6-only, but bindhost is IPv4-only). Reconnecting...

How I fix this '? <*status> Disconnected from IRC (Server address is IPv6-only, but bindhost is IPv4-only). Reconnecting... <!-- github-comment-id:267371596 -->
Author
Owner

I clear my binhost so many times even with soap its not working...

I clear my binhost so many times even with soap its not working... <!-- github-comment-id:267373774 -->
Author
Owner

What server are you trying to connect to? Try something that also has an IPv4 address (dunno, some freenode server?)

What server are you trying to connect to? Try something that also has an IPv4 address (dunno, some freenode server?) <!-- github-comment-id:267374334 -->
Author
Owner

ON DALnet Server @psychon

ON DALnet Server @psychon <!-- github-comment-id:267374525 -->
Author
Owner

Try 194.68.45.50 or 91.217.189.35 or 154.35.175.101 or 194.14.236.50 as server (random dalnet servers; however, I cannot find one with an IPv6-address; what server did you give ZNC to connect to?)

Try 194.68.45.50 or 91.217.189.35 or 154.35.175.101 or 194.14.236.50 as server (random dalnet servers; however, I cannot find one with an IPv6-address; what server did you give ZNC to connect to?) <!-- github-comment-id:267375027 -->
Author
Owner

My IP address is IPv6 and They said my bIndhost is IPv6 only? I don't understand this?

My IP address is IPv6 and They said my bIndhost is IPv6 only? I don't understand this? <!-- github-comment-id:267376159 -->
Author
Owner

Pardon me, but my psychic abilities are having a bad day: Who is "they" and what exactly do "they" say? Any more specific error message from ZNC?
Why do you even still have a bindhost after /msg *status clearbindhost? That should unset any bindhost.

Pardon me, but my psychic abilities are having a bad day: Who is "they" and what exactly do "they" say? Any more specific error message from ZNC? Why do you even still have a bindhost after `/msg *status clearbindhost`? That should unset any bindhost. <!-- github-comment-id:267377324 -->
Author
Owner

Man, I want to use my VHOST which I set from www.freedns.afraid.org. On IPv6 Address. But when I set the BindHost I get this message

Man, I want to use my VHOST which I set from www.freedns.afraid.org. On IPv6 Address. But when I set the BindHost I get this message <!-- github-comment-id:267378134 -->
Author
Owner

Uhm. That sounds more like ZNC's message is mixed up (is it?) and you are having an IPv6-bindhost, but DALnet does not have any IPv6 servers.
In that case, try /znc addserver ipv6.dal.net (or /znc addserver 2001:550:101:a::2 and /znc addserver 2a00:1a28:1100:4::a)

Uhm. That sounds more like ZNC's message is mixed up (is it?) and you are having an IPv6-bindhost, but DALnet does not have any IPv6 servers. In that case, try `/znc addserver ipv6.dal.net` (or `/znc addserver 2001:550:101:a::2` and `/znc addserver 2a00:1a28:1100:4::a`) <!-- github-comment-id:267545236 -->
Author
Owner

DALnet allow Ipv6 and on my ZNC panal i have put ipv6.dal.net server...

[Edit] [Del] DALnet 1 ipv6.dal.net:+6697 Fahad

Now what ? shall i add this also /znc addserver 2001:550:101:a::2

DALnet allow Ipv6 and on my ZNC panal i have put ipv6.dal.net server... [Edit] [Del] DALnet 1 ipv6.dal.net:+6697 Fahad Now what ? shall i add this also /znc addserver 2001:550:101:a::2 <!-- github-comment-id:267582165 -->
Author
Owner

And After setting my Vhost on afraid and i cant able to add Ipv6 Ip on my panal. It says Invalid Hostname.

And After setting my Vhost on afraid and i cant able to add Ipv6 Ip on my panal. It says Invalid Hostname. <!-- github-comment-id:267584245 -->
Author
Owner

and it says my bindhost is ipv4 only

Disconnected from IRC (Server address is IPv6-only, but bindhost is IPv4-only). Reconnecting...

and it says my bindhost is ipv4 only Disconnected from IRC (Server address is IPv6-only, but bindhost is IPv4-only). Reconnecting... <!-- github-comment-id:267584959 -->
Author
Owner

and it says my bindhost is ipv4 only

Disconnected from IRC (Server address is IPv6-only, but bindhost is IPv4-only). Reconnecting...

But didn't you say that your bindhost is an IPv6 address?
Here:

Man, I want to use my VHOST which I set from www.freedns.afraid.org. On IPv6 Address. But when I set the BindHost I get this message

I'm confused by your setup. And the use of "VHOST" confuses me further.
Can you tell me what you set up with freedns? (Which IP, which DNS name)

I think that you cannot use this to get a vhost...

> and it says my bindhost is ipv4 only > > Disconnected from IRC (Server address is IPv6-only, but bindhost is IPv4-only). Reconnecting... But didn't you say that your bindhost is an IPv6 address? Here: > Man, I want to use my VHOST which I set from www.freedns.afraid.org. On IPv6 Address. But when I set the BindHost I get this message I'm confused by your setup. And the use of "VHOST" confuses me further. Can you tell me what you set up with freedns? (Which IP, which DNS name) I think that you cannot use this to get a vhost... <!-- github-comment-id:267585799 -->
Author
Owner

@psychon OK I can explain... I purchase VPS ok and I setup my ZNC and after setting up my ZNC i try to set Vhost for ZNC which i did from www.freedns.afraid.org. I put my IPV6 ip and set my VHost i try to put that vhost on znc. I get this message...

@psychon OK I can explain... I purchase VPS ok and I setup my ZNC and after setting up my ZNC i try to set Vhost for ZNC which i did from www.freedns.afraid.org. I put my IPV6 ip and set my VHost i try to put that vhost on znc. I get this message... <!-- github-comment-id:267587719 -->
Author
Owner

The BindHost in ZNC just selects the IP address that ZNC connects from. If you only have a single IP address, the BindHost option doesn't have any effect.
Since you mention VHost: When the IRC server sees an incoming connection, it only sees your IP address. It then looks up the PTR record of that IP address to get a domain. Then it resolves that domain into an IP address. If the result matches the IP address of the incoming connection, the domain is used for display purposes instead of the IP address.
So, just setting up a new DNS record with freedns does not help, because you also need the PTR DNS record of the IP address (which you cannot control in most cases).

All of the above is why the option in znc is called BindHost and not VHost.

The BindHost in ZNC just selects the IP address that ZNC connects from. If you only have a single IP address, the BindHost option doesn't have any effect. Since you mention VHost: When the IRC server sees an incoming connection, it only sees your IP address. It then looks up the PTR record of that IP address to get a domain. Then it resolves that domain into an IP address. If the result matches the IP address of the incoming connection, the domain is used for display purposes instead of the IP address. So, just setting up a new DNS record with freedns does not help, because you also need the PTR DNS record of the IP address (which you cannot control in most cases). All of the above is why the option in znc is called BindHost and not VHost. <!-- github-comment-id:267598547 -->
Author
Owner

@psychon I think my VPS IP is Default IPV4 ? Maybe that's the issue?

@psychon I think my VPS IP is Default IPV4 ? Maybe that's the issue? <!-- github-comment-id:267601043 -->
Author
Owner

@psychon Thank You My Problem is solve

@psychon Thank You My Problem is solve <!-- github-comment-id:267656613 -->
Author
Owner

IPV6 disable!!!

Copy:

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

Edit: nano /etc/sysctl.conf

Paste and save!
and shutdown -r now


ZNC configuration no write bindhost!

And work reverse domain irc.

IPV6 disable!!! Copy: net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 Edit: nano /etc/sysctl.conf Paste and save! and shutdown -r now ------------------------------------------- ZNC configuration no write bindhost! And work reverse domain irc. <!-- github-comment-id:416129138 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#9