inet_pton(): Argument #1 ($ip) must not contain any null bytes

Saarbruecken

Active member
Affected version
2.3.8
I am trying to import users, nodes, threads and posts from another XF 2.3.8 forum to an existing XF 2.3.8.
However, I keep getting the error below. Any ideas?

Code:
php cmd.php xf:import
Starting import from XenForo 2.3...
 - Step 1 of 8: User groups               00:00:00 [4]
 - Step 2 of 8: Custom user fields        00:00:00 [0]
 - Step 3 of 8: Users                     00:00:00 [1]
 - Step 4 of 8: Nodes                     00:00:00 [2]
 - Step 5 of 8: Thread prefixes           00:00:00 [0]
 - Step 6 of 8: Custom thread fields      00:00:00 [0]
 - Step 7 of 8: Threads                   00:01:10 [12,841]

In Ip.php line 14:
                                                                  
  inet_pton(): Argument #1 ($ip) must not contain any null bytes
                                                                  

In Ip.php line 14:
                                                                  
  inet_pton(): Argument #1 ($ip) must not contain any null bytes 
                                                                  

xf:import [--processes PROCESSES] [--finalize]

Code:
ValueError: inet_pton(): Argument #1 ($ip) must not contain any null bytes in src/XF/Util/Ip.php at line 14

    inet_pton() in src/XF/Util/Ip.php at line 14
    XF\Util\Ip::stringToBinary() in src/XF/Import/Data/EntityEmulator.php at line 443
    XF\Import\Data\EntityEmulator->logIp() in src/XF/Import/Data/AbstractEmulatedData.php at line 93
    XF\Import\Data\AbstractEmulatedData->logIp() in src/XF/Import/Data/Post.php at line 37
    XF\Import\Data\Post->postSave() in src/XF/Import/Data/AbstractData.php at line 141
    XF\Import\Data\AbstractData->save() in src/addons/XFI/Import/Importer/XenForo2.php at line 1670
    XFI\Import\Importer\XenForo2->stepPosts() in src/XF/Import/Runner.php at line 246
    XF\Import\Runner->runStep() in src/XF/Import/Runner.php at line 61
    XF\Import\Runner->run() in src/XF/Admin/Controller/ImportController.php at line 247
    XF\Admin\Controller\ImportController->actionRun() in src/XF/Mvc/Dispatcher.php at line 362
    XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 264
    XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 121
    XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 63
    XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2824
    XF\App->run() in src/XF.php at line 814
    XF::runApp() in admin.php at line 15

Code:
Server environment report
You have the recommended PHP version.

PHP version
    8.4.16

MySQL version
    11.8.3 (11.8.3-MariaDB-0+deb13u1 from Debian)

Server software
    Apache/2.4.66

PHP memory_limit
    512M

PHP post_max_size
    64M

PHP upload_max_filesize
    64M

PHP max_input_vars
    1000

PHP max_execution_time
    300

cURL version
    8.14.1

cURL SSL version
    OpenSSL/3.5.4

OpenSSL version
    OpenSSL 3.5.4 30 Sep 2025

Snuffleupagus enabled
    No

Imagick support
    Yes

EXIF support
    Yes

GZip support
    Yes

gmp support
    Yes

intl support
    No

ZipArchive support
    Yes
 
I made a bug report earlier:

You can disable Cloudflare proxy for a quick workaround while importing tho.
 
Related issue?

This is weird. A test import from XF 2.3.8 with only few threads / post was successful, however, the original XF 2.3.8 import with > 12k threads keeps throwing the error.
 
I am trying to import users, nodes, threads and posts from another XF 2.3.8 forum to an existing XF 2.3.8.
However, I keep getting the error below. Any ideas?

Code:
php cmd.php xf:import
Starting import from XenForo 2.3...
 - Step 1 of 8: User groups               00:00:00 [4]
 - Step 2 of 8: Custom user fields        00:00:00 [0]
 - Step 3 of 8: Users                     00:00:00 [1]
 - Step 4 of 8: Nodes                     00:00:00 [2]
 - Step 5 of 8: Thread prefixes           00:00:00 [0]
 - Step 6 of 8: Custom thread fields      00:00:00 [0]
 - Step 7 of 8: Threads                   00:01:10 [12,841]

In Ip.php line 14:
                                                                 
  inet_pton(): Argument #1 ($ip) must not contain any null bytes
                                                                 

In Ip.php line 14:
                                                                 
  inet_pton(): Argument #1 ($ip) must not contain any null bytes
                                                                 

xf:import [--processes PROCESSES] [--finalize]

Code:
ValueError: inet_pton(): Argument #1 ($ip) must not contain any null bytes in src/XF/Util/Ip.php at line 14

    inet_pton() in src/XF/Util/Ip.php at line 14
    XF\Util\Ip::stringToBinary() in src/XF/Import/Data/EntityEmulator.php at line 443
    XF\Import\Data\EntityEmulator->logIp() in src/XF/Import/Data/AbstractEmulatedData.php at line 93
    XF\Import\Data\AbstractEmulatedData->logIp() in src/XF/Import/Data/Post.php at line 37
    XF\Import\Data\Post->postSave() in src/XF/Import/Data/AbstractData.php at line 141
    XF\Import\Data\AbstractData->save() in src/addons/XFI/Import/Importer/XenForo2.php at line 1670
    XFI\Import\Importer\XenForo2->stepPosts() in src/XF/Import/Runner.php at line 246
    XF\Import\Runner->runStep() in src/XF/Import/Runner.php at line 61
    XF\Import\Runner->run() in src/XF/Admin/Controller/ImportController.php at line 247
    XF\Admin\Controller\ImportController->actionRun() in src/XF/Mvc/Dispatcher.php at line 362
    XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 264
    XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 121
    XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 63
    XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2824
    XF\App->run() in src/XF.php at line 814
    XF::runApp() in admin.php at line 15

Code:
Server environment report
You have the recommended PHP version.

PHP version
    8.4.16

MySQL version
    11.8.3 (11.8.3-MariaDB-0+deb13u1 from Debian)

Server software
    Apache/2.4.66

PHP memory_limit
    512M

PHP post_max_size
    64M

PHP upload_max_filesize
    64M

PHP max_input_vars
    1000

PHP max_execution_time
    300

cURL version
    8.14.1

cURL SSL version
    OpenSSL/3.5.4

OpenSSL version
    OpenSSL 3.5.4 30 Sep 2025

Snuffleupagus enabled
    No

Imagick support
    Yes

EXIF support
    Yes

GZip support
    Yes

gmp support
    Yes

intl support
    No

ZipArchive support
    Yes
This error indicates that the XenForo Importer encountered corrupted or improperly formatted data while trying to process an IP address for a forum post.

Here is the breakdown of what is happening and how to fix it.

The Error in Plain English​

  • The Function: inet_pton() is a PHP function that takes a human-readable IP address (like 192.168.1.1) and converts it into a machine-readable binary format.
  • The Problem: The IP address string being passed to this function contains a "Null Byte" (\0). This is an invisible character (ASCII code 0) that often signifies the end of a string in lower-level programming but is illegal in the middle of a PHP string for this specific function.
  • The Context: You are running a XenForo 2 import (Step: Posts). One of the posts in your source database has an IP address that is likely "padded" with invisible null characters or is corrupted.

Why is this happening?​

This usually happens during database migrations or imports when:

  1. Data Corruption: The source database has a field (e.g., ip_address) that contains the IP followed by garbage characters or null padding (e.g., "127.0.0.1\0" instead of "127.0.0.1").
  2. Binary vs String Confusion: The importer might be reading a raw binary IP field from the old database but treating it as a text string, which accidentally includes null bytes.
 
Back
Top Bottom