You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SNMP::__construct() fails to resolve hostname with warning "Unknown failure while resolving hostname" #20752
Doesn't reproduce on my system.
Does this reproduce consistently for you? Do you have any special networking configuration that may interfere with this?
I do not have my usual ubuntu machine with me, however your script has the expected output on my mac with php 8.5.1.
So for whatever reason, netsnmp_session_init() fails for you, I may have a look next week unless someone does it faster.
I have Cact (https://www.cacti.net/)i running on PHP 8.3.27 on my VPS. I decided to try upgrading to 8.4.15 and got an error in the web interface saying that it was impossible to retrieve data via SNMP. But the console agent written in C++ worked and collected data. I took an interest in this case and found that the problem was in PHP with the SNMP constructor. One of the features of the VPS is that it does not have IPv6, only IPv4. What other details do you need?
Got this problem on FreeBSD 14.3 after upgrading net-snmp from 5.9.4 to 5.9.5.2 and recompiling php-snmp. Upgrading php from 8.4.16 to 8.5.1 did not resolve the problem.
I have found at least one bug in snmp.c in snmp_session_init. In my building environment (after upgrading net-snmp to 5.9.5.2) HAVE_GETADDRINFO is defined but HAVE_IPV6 is not defined. As a result session->peername variable is never "filled properly" after resetting it to '\0'.
Deleting #if defined(HAVE_GETADDRINFO) && defined(HAVE_IPV6) and corresponging #endif partially solved the problem - SNMP::__construct() stopped returning the error "Unknown failure..". But SNMP::walk() for this session returned the error "Could not open snmp connection: Unknown host (127.0.0.1) (Can't assign requested address)". Trying snmprealwalk() with same parameters did not return any errors.
I recommend checking entire php-snmp code for compatibility with new net-snmp 5.9.5.2 version.
Just cant wait for fix anymore, my scripts which using php-snmp not working since winter with net-snmp 5.9.5.2, and suddenly stopped working with net-snmp 5.9.4 now with php 8.5.12 after upgrade from php 8.5.11 (but looks like php upgrade is unrelated).
Guess since that much time has passed exp/snmp is dead and i need to rewrite these scripts somehow.
php 8.5.12 SNMP is still not working for me.
NET-SNMP version: 5.9.4.pre2 on both Ubuntu 24.04 and 26.04.
I am using a workaround for Cacti by disabling php-snmp.
Yes, managed to make net-snmp 5.9.4 working, but i needed to find and rebuild it manually because that version was completely removed from gentoo in march 2026. Was just keeping it in my system since then without touching so maybe some binary incompatibilities showed up. Can't use workarounds because scripts were writted with ext/snmp at first place, already tried to rewrite them using net-snmp cli tools but it not that trivial and was working slower with many snmp v1 queries. Ext/snmp somehow is faster than some other libraries (like python).
Activity
ndossche commentedon Dec 21, 2025
Doesn't reproduce on my system.
Does this reproduce consistently for you? Do you have any special networking configuration that may interfere with this?
devnexen commentedon Dec 21, 2025
I do not have my usual ubuntu machine with me, however your script has the expected output on my mac with php 8.5.1.
So for whatever reason, netsnmp_session_init() fails for you, I may have a look next week unless someone does it faster.
devnexen commentedon Dec 21, 2025
ah well sorry Niels :)
dshovchko commentedon Dec 21, 2025
I have Cact (https://www.cacti.net/)i running on PHP
8.3.27on my VPS. I decided to try upgrading to8.4.15and got an error in the web interface saying that it was impossible to retrieve data via SNMP. But the console agent written in C++ worked and collected data. I took an interest in this case and found that the problem was in PHP with the SNMP constructor. One of the features of the VPS is that it does not have IPv6, only IPv4. What other details do you need?azotov commentedon Jan 19, 2026
Got this problem on FreeBSD 14.3 after upgrading net-snmp from 5.9.4 to 5.9.5.2 and recompiling php-snmp. Upgrading php from 8.4.16 to 8.5.1 did not resolve the problem.
I have found at least one bug in snmp.c in snmp_session_init. In my building environment (after upgrading net-snmp to 5.9.5.2) HAVE_GETADDRINFO is defined but HAVE_IPV6 is not defined. As a result session->peername variable is never "filled properly" after resetting it to '\0'.
Deleting
#if defined(HAVE_GETADDRINFO) && defined(HAVE_IPV6)and corresponging#endifpartially solved the problem - SNMP::__construct() stopped returning the error "Unknown failure..". But SNMP::walk() for this session returned the error "Could not open snmp connection: Unknown host (127.0.0.1) (Can't assign requested address)". Trying snmprealwalk() with same parameters did not return any errors.I recommend checking entire php-snmp code for compatibility with new net-snmp 5.9.5.2 version.
devnexen commentedon Jan 19, 2026
Thanks for the hints @azotov I ll have a look soon-ish
safelock1 commentedon Feb 5, 2026
Maybe my problem is related to yours?:
#21132
devnexen commentedon Feb 6, 2026
partially at least very likely yes.
PM2D commentedon Oct 27, 2026
Just cant wait for fix anymore, my scripts which using php-snmp not working since winter with net-snmp 5.9.5.2, and suddenly stopped working with net-snmp 5.9.4 now with php 8.5.12 after upgrade from php 8.5.11 (but looks like php upgrade is unrelated).
Guess since that much time has passed exp/snmp is dead and i need to rewrite these scripts somehow.
safelock1 commentedon Oct 27, 2026
php 8.5.12 work ok (i'm tested) with net-snmp 5.9.4 (NET-SNMP version: 5.9.4.pre2) - i'm tested with my system
dshovchko commentedon Oct 27, 2026
php 8.5.12 SNMP is still not working for me.
NET-SNMP version: 5.9.4.pre2 on both Ubuntu 24.04 and 26.04.
I am using a workaround for Cacti by disabling php-snmp.
PM2D commentedon Oct 27, 2026
Yes, managed to make net-snmp 5.9.4 working, but i needed to find and rebuild it manually because that version was completely removed from gentoo in march 2026. Was just keeping it in my system since then without touching so maybe some binary incompatibilities showed up. Can't use workarounds because scripts were writted with ext/snmp at first place, already tried to rewrite them using net-snmp cli tools but it not that trivial and was working slower with many snmp v1 queries. Ext/snmp somehow is faster than some other libraries (like python).