Support » Fixing WordPress » undefined index: server_name in pluggable.php

  • I have been running my wp-cron from a real cronjob setup within my cpanel, using php-cli. I had no errors for a long time until recently i’ve been getting this:
    Undefined index: SERVER_NAME in /home/xxxx/public_html/

    This does not happen every time my cron runs, but it does happen about half the time. My hosting provider insists it’s a code issue and doesn’t have anything to do with them. I found something related to this, but not exactly the same thing…

    The odd thing is i run another site of the same hosting account and it does not get these errors… weird right?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz


    I suppose they could say it’s a code issue and code should check for its existence before using it, and if it is not defined, fall back to the server’s IP address. Since the functions are pluggable, this wouldn’t be too difficult to accomplish.

    OTOH, RFC 3875 states in part:

    4.1.14. SERVER_NAME — The SERVER_NAME variable MUST be set to the name of the server host to which the client request is directed.

    Edit: I give up trying to get the quote formatting right

    The MUST emphasis is not mine, it is part of the specification. So the server not setting this value means it is not in compliance with one of the basic Internet standards. That’s not a coding issue, that is a server configuration issue. Thus it’s reasonable for code to assume the value is set.

    To be fair, intermittent glitches are hard to debug. Your host probably checked the value once and it was OK, so they assumed it’s not their problem, so it has to be a coding problem.

    • This reply was modified 4 years, 10 months ago by bcworkz. Reason: quote formatting
    • This reply was modified 4 years, 10 months ago by bcworkz.
    • This reply was modified 4 years, 10 months ago by bcworkz.
    • This reply was modified 4 years, 10 months ago by bcworkz.
    Thread Starter derekakelly



    Thanks for your reply. I relayed your message to my hosting provider and this was their response.

    In your post, you mention that you run another website from the same account that does not generate said issue. This clearly indicates that the problem is not with the server setup. It could be a conflict between the website’s settings and the server, but without being able to replicate the issue, it is hard to confirm. If you have noticed any particular pattern when the error occurs, let us know.

    I’ve re-enabled debug logging on my other website to re-confirm that my other website is not experiencing the same issue. I’ll post again next week.

    Thanks and Happy Holidays!

    Moderator bcworkz


    I wasn’t sure if “same hosting account” equated to same server. With some hosts this is not necessarily the case. It is possible for software to unset the sever name, though I can’t imagine why. One could install an error trap in wp-config.php that logs any occurrence of the value not being set. Since wp-config.php is nearly the first code executed, any errors here would indicate a server glitch. Subsequent errors in pluggable.php that are not logged here would indicate a software glitch.

    Doesn’t solve the problem, but narrows down where to look.

    Enjoy the Holidays 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘undefined index: server_name in pluggable.php’ is closed to new replies.