How to Fix the HTTP Error 503 Service Unavailable - Kinsta

文章推薦指數: 80 %
投票人數:10人

The 503 (Service Unavailable) status code indicates that the server is currently unable to handle the request due to a temporary overload or ... Skiptocontent FindouthowmovingtoKinstacouldsaveyou$2,400+ayearonsitecosts. Home ResourceCenter KinstaBlog HowtoFixtheHTTPError503ServiceUnavailableinWordPress MatteoDuò, June2,2022 124 Shares RunningintoerrorsonyourWordPresssitecanbeintimidating.However,mosterrorsgiveyousomeclueastowhatcausedthem,whichcanmaketroubleshootingthesecommonissuesaloteasier.The503errorisnotaspolite,unfortunately,anddoesn’tgiveyoumuchinformationtogoon. Ithelpstounderstandwhatthemostcommoncausesareforthe503errorinWordPress.Afterthat,you’llneedtobemethodicalwhenitcomestotroubleshootingtheerror,whichmeansfollowingseveralstepsinordertolocatetherootcause. What'stheHTTP503ServiceUnavailableError? The503errorinWordPresssignifiesthatyourwebsitecan’tbereachedatthepresentmomentbecausetheserverinquestionisunavailable.Thiscouldhappenbecauseit’stoobusy,undermaintenance,orsomethingelsewhichrequiresadeeperanalysis. Support Inthisarticle,we’llcoverwhatthe503errorisandhowittypicallymanifests.Thenwe’llguideyouthroughsixstepsinordertotroubleshootit.Let’sgettowork! WhatIsanHTTPError503? TheInternetEngineeringTaskForce(IETF)definesthe503ServiceUnavailableas: The503(ServiceUnavailable)statuscodeindicatesthattheserveriscurrentlyunabletohandletherequestduetoatemporaryoverloadorscheduledmaintenance,whichwilllikelybealleviatedaftersomedelay.TheserverMAYsendaRetry-Afterheaderfieldtosuggestanappropriateamountoftimefortheclienttowaitbeforeretryingtherequest. Whenyouencounterthe503error,itmeansthattheserverinquestionisunavailable.Thatcouldbebecauseit’stoobusy,forexample,orit’sundermaintenance.Unlikeothersimilarerrorcodes,503signifiesthatyourwebsiteisonlineandrunning,butcan’tbereachedatthepresentmoment. SeehowKinstastacksupagainstthecompetition. Selectyourprovider WPEngine SiteGround GoDaddy Bluehost Flywheel HostGator Cloudways AWS DigitalOcean DreamHost Other Compare What’ssovexingaboutthisparticularerroristhatitbarelygivesyouanyinformationtogoon.Mostofthetime,itjustshowsupwitha“Servicetemporarilyunavailable”message.That’stheequivalentofcallingarestaurantviaphone,onlytohavethemtellyouthatthey’reclosedbutrefusetoletyouknowwhenthey’llbeopenagain. Ifyou’relucky,the503errorcodewillhaveoccurredbecauseyourWordPresswebsiteisundermaintenance.WordPressverybrieflysetsyoursitetomaintenancemodewhenyou’reupdatingaplugin,atheme,orthecoresoftware: Maintenancemode Usually,thistimeoutissobriefthatnoonewillnoticeit.However,inthosecaseswherethe503errorpersists,you’llhaveabiggerproblemtodealwith.Afterall,notonlywillusersbeunabletovisityoursite,butyou’llloseaccesstoyourWordPressadminareaaswell.Thatmeansyoucan’tupdateyoursiteinanyway,andinordertotroubleshootit,you’llneedtodigintoitsfiles. CheckOutOurVideoGuidetoThe503Error 503ErrorVariations The503errorcanshowupinalotofways.However,almosteveryvariationcomesaccompaniedbythat503code,makingiteasytoidentify. Herearesomeofthevariationsyoumightencounter,dependingonyourserverconfigurationandbrowser: 503ServiceUnavailable 503ServiceTemporarilyUnavailable HTTPServerError503 HTTPError503 Error503ServiceUnavailable Theserveristemporarilyunabletoserviceyourrequestduetomaintenancedowntimeorcapacityproblems.Pleasetryagainlater. Whateverthecodeyourunintomightlooklike,itmeansyouneedtogettoworkfastbeforeitaffectsyourusersnegatively. Haveyoueverrunintothe503errorinWordPress?That'sabummer!😱Followthese6stepstofixitandgetyoursitebackonlineinnoseconds!ClicktoTweet HowtoFixthe503ErrorinWordPress(6Steps) Sinceyouoftencan’tbesurewhatcausedthe503errorinanygivensituation,you’llneedtogoabouttroubleshootingitmethodically.Thefollowingsixsectionseachcoverapotentialfix,aimedatresolvingthedifferentpotentialrootcauses. Aftereachstep,takeamomenttoreturntoyourwebsiteandseeifthe503errorisgone.Ifitis,you’vesuccessfullyfixedtheissue.Ifnot,continueontothenextstepintheprocess. 1.TemporarilyDeactivateYourWordPressPlugins Oneofthemostcommoncausesofthe503errorinWordPressisplugincompatibilityissues.Todetermineifthat’swhat’shappening,you’llneedtodisableallofyoursite’splugins. Sincethe503errorpreventsyoufromaccessingtheWordPressadminarea,you’llneedtouseanFTPclientforthisstep.Ifyoudon’thaveonesetup,werecommendFileZilla. OnceyourFTPclientisready,connecttoyourwebsitethroughitandnavigatetoyourWordPressrootfolder.Incaseyoucan’tfindit,it’susuallycalledpublic_html,html,public,www,oryoursite’sname.Ifyou’reaKinstaclient,it’syourpublicfolder. WordPressrootfolderSFTP Openthatfolder,andnavigatetothewp-contentdirectory.Inside,you’llseeafoldercalledplugins,whichcontainsindividualsubdirectoriesforeachofthepluginsinstalledonyoursite(bothactiveandinactive). Whatyou’regoingtodonowisright-clickonthepluginsfolder,andrenameittosomethingelse.Werecommendplugins.oldorplugins.deactivated,soyoucaneasilyrecognizeitlater. WordPresspluginsfolderrenamed WordPresswillnownotbeabletofindanyofyourplugins.Whenthathappens,itwillautomaticallydisablethoseplugins. Now,tryaccessingyourWordPressdashboard.Ifthe503errorisgone,thenyoucanassumethatoneofyourpluginswastheculprit.Allyouhavetodoisfigureoutwhichonewasatfault. Returntothewp-contentdirectory,andrenameyouroriginalpluginsfoldercorrectly.Then,you’llneedtodisableeachofyourpluginsonebyone,untilyoufindtheculprit. Todothis,openthewp-content/pluginsdirectory.Inside,you’llfindonefolderforeachofyourplugins.Theprocessyou’regoingtofollowismuchthesameasbefore: Startwiththefirstfolder,andrenameittoanythingyoulike. Checkyourwebsitetoseeiftheerrorisgone. Ifitisn’t,returnthepluginfolderfromtheprevioussteptoitsoriginalname. Moveontothenextpluginonyourlist,repeatingtheabovesteps. Thisprocesscantakeawhileifyouhavealotofplugins,butit’svitaltocheckeachplugininturn.Ifatanypointyouidentifythepluginthat’scausingtheerror,youcanuninstallitorreplaceitwithanothertool. Ifyoumakeittotheendofthesestepswithoutfindingasolution,youcanmoveontothenextstageoftroubleshooting. 2.DeactivateYourWordPressTheme Nowthatyou’veruledoutyourpluginsasthecauseofthe503error,it’stimetodothesamewithyouractivetheme.Infact,yourthemecouldalsobecreatingcompatibilityissues. Unfortunately,theprocessdoesn’tworkthesameasabove.WordPresswon’treverttothedefaultthemeifsimplyrenamethethemefolder,youwouldendupwithanerrorlike“Thethemedirectory“themename”doesnotexist.”Orifyoutrytorenametheentirethemedirectoryfolder,youendupwith“ERROR:Thethemesdirectoryiseitheremptyordoesn’texist.Pleasecheckyourinstallation.” Thethemedirectorydoesnotexisterror Therefore,youneedtoaccessyourWordPressdatabasebyloggingintophpMyAdmin.Ifyou’reaKinstaclient,thiscanbefoundwithinthe“Info”sectionoftheMyKinstadashboard. MyKinstaphpMyAdmin Clickintothe“wp_options”table,thenclickonthe“Search”tab.Youwillwanttosearchunderthe“option_name”fortemplate. SignUpFortheNewsletter Wanttoknowhowweincreasedourtrafficover1000%? Join20,000+otherswhogetourweeklynewsletterwithinsiderWordPresstips! SubscribeNow phpMyAdminwp_optionstable Underthe“option_value”columnyouwillseethecurrentnameofyourtheme.Changethistooneofthedefaultthemes,suchas“twentynineteen.” wp_optionstemplatename Checkyourwebsiteagaintoseeifthishasfixedtheerror.Ifitdid,itsimplymeansit’saproblemwithyourWordPressthemeandyoumightwanttotryreinstallingitorrevertingtoyourmostrecentbackup. 3.TemporarilyDisableYourContentDeliveryNetwork(CDN) Sometimes,the503errorwillshowupnotbecauseofaproblemonyourwebsite,butbecauseofyourContentDeliveryNetwork(CDN).Ifyou’reusingaCDN,aquickwaytofigureoutifthat’sthecaseistotemporarilydisableit. EveryCDNshouldincludesomefeaturethatenablesyoutopauseitsservices.Ifyou’reonKinsta,youcandisableyourKinstaCDNbynavigatingtoCDN→“DisableCDN”insideyourMyKinstadashboard: MyKinstaCDNenable/disableoption TheprocessyouneedtofollowmaybedifferentdependingonwhichCDNyou’reusing.Cloudflarehasalsobeenknowntocause503errorssometimes.Ifyoucan’tfindtheoptiontopauseyours,checkoutyourservice’sknowledgebase,whichwillusuallycontaindetailedinstructions. Ifyoudon’tuseaCDNorfindthatpausingyourservicedoesn’thelpwithyourissue,therearestillafewmorefixestotry.DoremembertoreactivateyourCDNbeforemovingon. 4.LimittheWordPress‘Heartbeat’API TheWordPressHeartbeatisanAPIbuiltintoWordPress,whichtheplatformusesforauto-savingcontent,showingyoupluginnotifications,lettingyouknowwhensomeoneelseisworkingonapostyou’retryingtoaccess,andmore. Justlikearegularheartbeat,theAPIworksinthebackgroundwithahighfrequencysothatitdoesn’tmissanything.Asyoumightimagine,thisAPIconsumesserverresources.Usually,that’snotaproblembutinsomecases,itmayleadtoa503errorifyourservercan’thandletheload. ThequickestwaytodetermineiftheHeartbeatAPIisatthecenterofyourproblemsistotemporarilydisableit.Todothat,connecttoyourWordPresswebsiteviaFTPoncemore,andthenopenyourcurrentthemesfolderandlookforthefunctions.phpfilewithin: WordPressthemefunctions.phpfile Right-clickonthefileandselecttheView/Editoption,whichwillopenitusingyourlocaltexteditor.Onceit’sopen,you’llneedtoaddthefollowingcodesnippetwithin: TiredofdealingwithdowntimeandWordPressissues?Kinstasupportchecksthestatusofyourwebsiteevery2minutestoanticipateanymajorhiccupsandproactivelyact.Checkoutourplans add_action('init','stop_heartbeat',1); functionstop_heartbeat(){ wp_deregister_script('heartbeat'); } ThosethreelinesofcodetellWordPresstodisabletheHeartbeatAPI.Savethechangestothefunctions.phpfile,closeit,andtrytoaccessyourwebsiteagain. Ifthe503errorisgone,you’llknowthattheAPIwastheproblem.Disablingitaltogetherremovesalotofusefulfunctionality,however.Instead,werecommendthatyou‘slowdown’theHeartbeat,sothatitdoesn’tcauseproblems. TheeasiestwaytodothatisbyinstallingtheHeartbeatControlplugin.ActivatethepluginandnavigatetotheSettings>HeartbeatControlsection.LookfortheModifyHeartbeatoptions,anddropthefrequencytothelowestpossiblenumber: HeartbeatControlpluginfrequency Savethechangestoyoursettingsandreturntothefunctions.phpfileyoutweakedawhileback.Fortheabovechangestowork,you’llneedtoremovethestringofcodeyouaddedbeforeandsaveyourchangestothefile. Atthisstage,the503errorshouldbegoneiftheHeartbeatAPIwastheproblem.Ifitisn’t,thenit’stimetotrysomethingdifferent. 5.IncreaseYourServer’sResources Ifthe503errorisstilloccurringdespiteallyourattemptstofixitsofar,thenthere’sagoodchancetheproblemmightbeduetoalackofserverresources.Thatistosay,you’llneedtoupgradeyourhostingplantoseeifthatfixestheissue.Thisisespeciallytrueifyou’reusingcheapWordPresshosting,astheytendtothrottleresources.Wedon’tdothisatKinsta. Upgradingyourplanisabigdecision,however.Thesmartmoveistofirstcontactyourwebhostingsupportserviceanddiscussthe503errorwiththem,aswellasthestepsyou’vetakensofartotryandsolveit.Thesupportteamshouldbeabletohelpyouworkoutthecauseandadviseyouonwhetheryouneedtoupgradeyourplanornot. 6.ReviewYourLogsandEnableWP_DEBUG You shouldalsotakeadvantageofyour errorlogs.Ifyou’reaKinstaclient,youcaneasilyseeerrorsinthelogviewerandenableWordPressdebugmodeintheMyKinstadashboard.Thiscanhelpyouquicklynarrowdowntheissue,especiallyifit’sresultingfromapluginonyoursite. Checkerrorlogsfor503errors Ifyourhostdoesn’thavealoggingtool,youcanalsoaddthefollowingcodetoyourwp-config.phpfiletoenablelogging: define('WP_DEBUG',true); define('WP_DEBUG_LOG',true); define('WP_DEBUG_DISPLAY',false); Thelogsaretypicallylocatedinthe/wp-contentdirectory.Insideit,lookforafilecalleddebug.logandopenitup. Others,likehereatKinstamighthaveadedicatedfoldercalled“logs”. WordPresserrorlogsfolder(SFTP) Interpretingyourdebuglogcanbeabitintimidatingbutit’snotashardtoreadasyoumightimagine.Inanutshell,thelogcontainseacherrorthatpopsuponyoursiteinchronologicalorder.Itshowswhichfilecausedeacherror,aswellaswhichspecificlinesofcodewereinvolved. Beware:you’renotgoingtofinddirectreferencestothe503errorwithinyourlog.Evenso,ifallelsefails,itcanpointyouintherightdirectionbyshowingyouwhatfilesarecausingproblems.Thatway,you’llknowwheretofocusyoureffortsnext.Aswementionedinthepreviousstep,nowisagoodtimetogetintouchwithyourhostingproviderifyouneedfurtherassistanceresolvingthiserror. Youcanalsocheckthelogfilesin Apache and Nginx,whicharecommonlylocatedhere: Apache: /var/log/apache2/error.log Nginx: /var/log/nginx/error.log Tolearnmore,pleasecheckoutourwebservershowdown:NginxvsApache. Ifyou’reaKinstaclientyoucanalsotakeadvantageofour analyticstooltogetabreakdownofthetotalnumberof503errorsandseehowoftenandwhentheyareoccurring.Thiscanhelpyoutroubleshootifthisisanongoingissue,orperhapssomethingthathasresolveditself. Ifthe503errorisdisplayingbecauseofafatalPHPerror,youcanalsotryenablingPHPerrorreporting.Simplyaddthefollowingcodetothefilethrowingtheerror.TypicallyyoucannarrowdownthefileintheconsoletabofGoogleChromeDevTools. ini_set('display_errors',1); ini_set('display_startup_errors',1); error_reporting(E_ALL); Andyoumightneedtoalsomodifyyourphp.inifilewiththefollowing: display_errors=on Summary Ifyou’relucky,the503errorwillonlyshowupwhenyouputyourwebsiteintomaintenancemode.However,ifitappearswithoutwarning,thenyou’llhavetorollupyoursleevesanddosometroubleshooting. Togetattherootcauseofthe503error,you’llneedtofollowthesestepstofixit: TemporarilydeactivateyourWordPressplugins. DeactivateyourWordPresstheme. DisableyourCDN. LimittheWordPressHeartbeatAPI. Increaseyourserverresources. ReviewyourlogsandenableWP_DEBUG. HaveyoueverrunintotheHTTP503errorinWordPress?Shareyourexperienceswithusinthecommentssectionbelow! Savetime,costsandmaximizesiteperformancewith: InstanthelpfromWordPresshostingexperts,24/7. CloudflareEnterpriseintegration. Globalaudiencereachwith34datacentersworldwide. Optimizationwithourbuilt-inApplicationPerformanceMonitoring. Allofthatandmuchmore,inoneplanwithnolong-termcontracts,assistedmigrations,anda30-day-money-back-guarantee.Checkoutourplansortalktosalestofindtheplanthat’srightforyou. Hand-pickedrelatedarticles Blog HowtoFixa403ForbiddenErroronYourWordPressSite The403Forbiddenerrorindicatesthattheserverunderstoodtherequestbutrefusestoauthorizeit.Findoutmoreaboutthecausesandfixes. Readingtime 11minread Publishdate January7,2019 Blog HowtoFixError404NotFoundonYourWordPressSite TheError404NotFoundstatuscodeindicatesthattheoriginserverdidnotfindthetargetresource.Checkoutthesecommoncausesandfixes. Readingtime 12minread Publishdate August22,2018 Comments LeaveAComment Andy July20,2021at12:06pm Reply Thankyouforthearticle.Overthepast3months,the503errorhasbeenonmysite5times.NowIthinkthatIneedtochangehostinginordertoavoidproblemsinthefuture. LeaveaReplyCancelreplyCommentpolicy:Welovecommentsandappreciatethetimethatreadersspendtoshareideasandgivefeedback.However,allcommentsaremanuallymoderatedandthosedeemedtobespamorsolelypromotionalwillbedeleted. CommentName Email Bysubmittingthisform:YouagreetotheprocessingofthesubmittedpersonaldatainaccordancewithKinsta'sPrivacyPolicy,includingthetransferofdatatotheUnitedStates. YoualsoagreetoreceiveinformationfromKinstarelatedtoourservices,events,andpromotions.Youmayunsubscribeatanytimebyfollowingtheinstructionsinthecommunicationsreceived.



請為這篇文章評分?