How to change the hostname, and port number – whether for staging or not

This topic has 5 replies, 3 voices, and was last updated 2 weeks ago ago by Tony Rodriguez

  • Avatar: payam
    payam
    Participant
    November 17, 2025 at 03:59

    I move the staging from one machine to another, server. Port 80 was taken and used by by other applications, so I need to move to a different port, e.g. 8080 and for ssl 8443.

    I’m using 8080 for testing now.
    I changed the hostname:port, in siteurl and home value in the database. Also, using Elementor > Tools > Permalink I did save with the correct port. Dumping the database shows there are still many instances that are not changed. I noticed that since some images were not loading.
    By replacing them using string replacement arrays break, and I get a php errors for unserialized values. I just left a part of one row below (of many). As we can see, the length of the path precedes the value (e.g. in this case 89 is the length ;s:89:\”http://localhost/wordpress/wp-content/uploads/custom-fonts/2025/08/RedditSans-Regular.ttf\”;) . There were recommendations for using wp-cli search-replace, but that did match anything.

    ..\..\php\wp.bat search-replace ‘localhost/wordpress’ ‘localhost:8080/wordpress’ –all-tables –dry-run

    How to replace the hostname, and ensure the serialized data length is corrected.

    INSERT INTO wp_options (option_id, option_name, option_value, autoload) VALUES
    […],
    (629, ‘etheme-fonts’, ‘a:3:{i:0;a:4:{s:2:\”id\”;i:8185126;s:4:\”name\”;s:18:\”RedditSans-Regular\”;s:4:\”file\”;a:6:{s:4:\”name\”;s:22:\”RedditSans-Regular.ttf\”;s:4:\”type\”;s:24:\”application/octet-stream\”;s:4:\”size\”;i:134428;s:9:\”extension\”;s:3:\”ttf\”;s:4:\”time\”;s:19:\”2025-08-10 06:52:07\”;s:3:\”url\”;s:89:\”http://localhost/wordpress/wp-content/uploads/custom-fonts/2025/08/RedditSans-Regular.ttf\”;}s:4:\”user\”;a:3:{s:10:\”user_email\”;s:8:\”imported\”;s:10:\”user_login\”;s:8:\”imported\”;s:5:\”roles\”;s:8:\”imported\”;}}i:1;a:4:{s:2:\”id\”;i:2331787;s:4:\”name\”;s:19:\”RedditSans-SemiBold\”;s:4:\”file\”;a:6:{s:4:\”name\”;s:23:\”RedditSans-SemiBold.ttf\”;s:4:\”type\”;s:24:\”application/octet-stream\”;s:4:\”size\”;i:135000;s:9:\”extension\”;s:3:\”ttf\”;s:4:\”time\”;s:19:\”2025-08-10 06:52:08\”;s:3:\”url\”;s:90:\”http://localhost/wordpress/wp-content/uploads/custom-fonts/2025/08/RedditSans-SemiBold.ttf\”;}s:4:\”user\”;a:3:{s:10:\”user_email\”;s:8:\”imported\”;s:10:\”user_login\”;s:8:\”imported\”;s:5:\”roles\”;s:8:\”imported\”;}}i:2;a:4:{s:2:\”id\”;i:9006941;s:4:\”name\”;s:17:\”RedditSans-Medium\”;s:4:\”file\”;a:6:{s:4:\”name\”;s:21:\”RedditSans-Medium.ttf\”;s:4:\”type\”;s:24:\”application/octet-stream\”;s:4:\”size\”;i:134840;s:9:\”extension\”;s:3:\”ttf\”;s:4:\”time\”;s:19:\”2025-08-10 06:52:09\”;s:3:\”url\”;s:88:\”http://localhost/wordpress/wp-content/uploads/custom-fonts/2025/08/RedditSans-Medium.ttf\”;}s:4:\”user\”;a:3:{s:10:\”user_email\”;s:8:\”imported\”;s:10:\”user_login\”;s:8:\”imported\”;s:5:\”roles\”;s:8:\”imported\”;}}}’, ‘auto’),

    […],

    4 Answers
    Avatar: Justin
    Luca Rossi
    Support staff
    November 17, 2025 at 05:31

    Hello Payam,

    Are you currently working on the live or staging sites, or only on your local host?

    If you are using a local host, we will not be able to log in and perform testing.

    To safely update the URLs, we recommend using the official WordPress CLI command without the --dry-run flag once you have verified the results:

    
    wp search-replace 'http://localhost/wordpress' 'http://localhost:8080/wordpress' --all-tables
    

    This command automatically manages serialized data and updates string lengths correctly.

    After completing the replacement, please clear any caching plugins and regenerate Elementor data by navigating to Elementor > Tools > Regenerate CSS & Data.

    Kindly let us know if you continue to experience any issues after these steps. We will be happy to assist you further.

    Best regards,
    8Theme Team

    Avatar: payam
    payam
    Participant
    November 18, 2025 at 05:57

    Thank you for clarification. I got this working, with your guideline. It was not a one hit fix. I will put details for those who encounter the same.

    So, after migrating to the new place, and importing the old db….
    1) In Elementor > Setting > Permalink add port (and change hostname)
    2) Update SiteURL and host using Elementor > Tools > Advanced > Replace URL

    Now after dumping the db, and you will see more need change (which was my problem):
    3) wp search-replace didn’t match anthing for me. Use https://github.com/interconnectit/Search-Replace-DB
    Clone the repo under htdocs (webserver). Navigate to the page. Set db/user/password/host and replace localhost/wordpress with localhost:8080/wordpress.
    I will give errors, but do it (and not in test mode).
    If it works, that’s perfect if not make a perl script to match patterns like
    s::\”http://localhost/wordpress/ and inplace replace it with
    s::\”http://localhost:8080/wordpress/
    (copilot did it for me)

    Dump the db again, and you may see \\/\\/localhost\\/wordpress\\. If not you may skip the next step.

    4) In the DB dump, I
    replaced them with \\/\\/localhost:8080\\/wordpress\\. This part was not array element preceding size. No adjustments were needed. Import the updated db.

    5) Elementor > Tools > General Clear Files & Data

    Now, all the element and images should be shown properly in the website.

    Avatar: payam
    payam
    Participant
    November 18, 2025 at 05:57

    Thanks for the support! My topic “How to change the hostname, and port number – whether for staging or not” has been successfully resolved.

    Avatar: Tony Rodriguez
    Tony Rodriguez
    Support staff
    November 18, 2025 at 05:57

    Dear payam,

    It’s great having you in our WordPress & WooCommerce community!

    Every insight you share helps us refine XStore and build tools that empower thousands of online store owners worldwide.

    Together, we grow stronger with every release.

    Topic closed.
    The 8Theme Team

  • Viewing 5 results - 1 through 5 (of 5 total)

The issue related to '‘How to change the hostname, and port number – whether for staging or not’' has been successfully resolved, and the topic is now closed for further responses

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.