503 Service Unavailable Error: What It Is and How to Fix It

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

There could be a bottleneck within your app's server chain causing a 503 Error. One of the simplest solutions to this is to restart the web ... SkiptoprimarynavigationSkiptomaincontentSkiptofooterA503ServiceUnavailableErrorisanHTTPresponsestatuscodeindicatingthataserveristemporarilyunabletohandletherequest.Thismaybeduetoanoverloadedserveroraserverthat’sdownformaintenance. Thisparticularresponsecodediffersfromthe500InternalServerErrorweexploredsometimeago.Whilea500InternalServerErrorindicatesanissuepreventingtheserverfromhandlingtherequestentirely,a503ServiceUnavailableErrorindicatesthattheserverisstillfunctioningproperlyandcanprocesstherequest,buthasoptedtoreturnthe503 responsecode. TherearedozensofpossibleHTTPstatuscodesusedtorepresentthecomplexrelationshipbetweentheclient,awebapplication,awebserver,andmultiplethird-partywebservices.Asyoucanimagine,determiningthecauseofaparticularstatuscodecanbechallenging.That’swhy,inthisarticle,we’llexaminethe503ServiceUnavailableErrorin-depth.Bytheendofthisarticle,you’llknowwhata503ServiceUnavailableErrorisandhowtotroubleshootandfixit. TheProblemisServer-Side AllHTTPresponsestatuscodesthatareinthe5xxcategoryare servererrorresponses.Unlikethe502BadGatewayError,whichindicatesthataserversomewhereintheconnectionchainisdownorunavailable;a503ServiceUnavailableError indicatesthattheserveristemporarilyunabletohandletherequestbutisotherwisefunctioningasnormal.Furthermore,unlikegateway-related5xxresponsecodesthatindicateissueseitheronthewebserveroranotherserverfurtherupstream,the503Errorcodeindicatesanissueontheactualwebserverhostingyourapplication. Inmostcases,thewebservershouldprovideauser-friendlypageshowingthattheserviceistemporarilyunavailable.Additionally,theapplicationshouldsendaResponse-AfterHTTPheader.Thisheadershouldinformtheuseragent(client)howlongitshouldwaittoattempttherequestagain.ThisvalueshouldeitherbeaDatevalueindicatingthetimestamptheservicewillbeavailable,oranumericvalueindicatinghowmanysecondsfromnowtheuseragentmustwaittoretry. Sincea503Error meanssomethingiswrongwiththeserverofyourapplication,youcandisregardtheclientsideofthings.Thatmeansyoucanignoremostclient-sidecodeandcomponents,suchasHTML,cascadingstylesheets(CSS),client-sideJavaScript,etc. Thisdoesn’tapplysolelytowebsites,either.Normalwebapplicationswilloftenpowersmartphoneappsthathaveamodern-lookinguserinterface.Ifa503ServiceUnavailableErroroccursonasmartphoneapp,theissuewilllieoutsideoftheinstalledapp.Theproblemwillbesomethingontheserver-side,whichperformsmostofthelogicandprocessingfortheapp.  That’sthe503ServiceUnavailableErrorinanutshell.Inthenextsection,we’llgooverhowtodiagnoseandfixthiserror. StartWithaThoroughApplicationBackup Beforeattemptinganyfixesorchangestothesystem,performafullbackupofyourapplication,database,andsoforth.Otherwise,youmightfindyourselfwithadditionalerrorsandlatenterrors.Ifyouhavethecapability,createacompletecopyoftheapplicationontoasecondarystagingserverthatisn’t“live.”Thiswillgiveyouacleantestinggroundtotestallpotentialfixestoresolvetheissuewithoutthreateningthesecurityorsanctityofyourliveapplication. Diagnosinga503ServiceUnavailableError Asmentionedbefore,a503Errorindicatesthattheserver(typicallytheactualwebserveronwhichyourapplicationisrunning)istemporarilyunavailable.Thisisusuallyduetotheserverbeing“down”forscheduledmaintenanceorduetoaheavytrafficloadthatpreventsitfromproperlyservingallincomingrequests. TheServerisDownforMaintenance A503Errorshouldpopupiftheserverisdownformaintenance.Theserverhasnotactuallycrashedorshutdownbutisinamodeofservicethatpreventsrequestsfrombehavingasnormal.Thatiswhyaoncenormally-functionalpagewilldisplaya 503ServiceUnavailableError, alongsideamessageabouttheserverbeingdownformaintenance.Onlyadministratorswillhaveaccesstotheserver,whereasnormalpublicrequestswillbeturnedawayuntilmaintenanceiscomplete. TheServerisOverloaded Aserverwillrejectrequestsduetooverloadfromanunexpectedonslaughtoftrafficandincomingrequests.Basically,theserverhasthrottleditselfinordertomaintainsomesemblanceofnormalbehaviorforaportionofrequests.Iftheapplication/serverisconfiguredcorrectly,youshouldbeabletocompletetherequestbywaitingandretryingafewtimes.Bywaiting,thetrafficspikeshoulddiedownandletyouin. Iftheerrorisnottheresultofmaintenanceoroverload,thenyou’llneedtotroubleshootfurther. We’llgooversometroubleshootingtipsandtrickstohelpyouresolvethisissue.Ifnothinghereworks,don’tforgetthatGoogleisyourfriend.Searchforspecifictermsrelatedtoyourissues.Chancesareyou’llfindotherswhohaveexperiencedthisissueandfoundwaystoresolveit. TroubleshootingontheServer-Side Mostofthetime,a503ServiceUnavailableErrorresultsfrommaintenanceoratrafficoverload.Whenthat’snotthecase,herearesomeadditionaltipstohelpyoutroubleshootwhatmightbecausingthiserror. ReboottheServer Therecouldbeabottleneckwithinyourapp’sserverchaincausinga503Error.Oneofthesimplestsolutionstothisistorestartthewebserverhostingtheapplication.Ifyourapplicationisspreadovermultipleservers,makesureallarerebootedproperlytobringthesystembackonlineasnormal. CheckforUnexpectedMaintenance Yourserverand/orapplicationmaybeautomaticallyconfiguredtogodownformaintenance.Manymoderncontentmanagementsystems,likeWordPress,willautomaticallydownloadandinstallupdatestotheirbasesoftwarewithoutanyinterventiononyourbehalf.Thewebservercouldbeissuinga 503ServiceUnavailableError duringthisperiod.Ifyou’reabletoaccesstheadministrationsettingsofyourapplication/server,checktheconfigurationoptionsforautomaticmaintenancescheduling.Youmayhavetheoptiontodisablethissettingifyou’dratherhavedirectcontroloverthatprocess. Don’tforgettoupgradetonewerversionsfairlyregularly,astheytypicallyincludecriticalsecurityfixes. ServerConnectivityIssues A503Errormayindicatethataserversomewhereinthechainisdownorunreachable.Mostmodernapplicationsdon’tresideonasingleserver.Instead,applicationsarespreadovermultiplesystemsorrelyonthird-partyservicestofunction.Ifoneoftheseserversgoesdown,youmightseea503Errorthatappearstobefromyourownapplication. ImproperFirewallConfiguration Afirewallisabasicsecuritydevicethatmonitorsnetworktrafficandactsasagatekeeper.Ithelpsdecidewhichtrafficissafeandwhichcouldbemalicious.Inmostcases,firewallsstoppotentiallyharmfultraffic(andmaybeloggedfornetworkadminuse).Butit’spossiblethatafirewallconfiguredsomewhereonthenetworkispreventingcriticaltrafficfromgettingthrough.Thisisparticularlytrueforapplicationsthatrelyoncontentdeliverynetworks(CDNs).TheseCDNsactasathird-partyhostfor“heavy”contentlikeimagesorvideosonbehalfofyourapplication,soyourapplicationcanmaintainitsspeedandefficiency.However,automaticfirewallservicessometimesperformfalsepositives,mistakingperfectlysafeandvalidcontentfromCDNsasmalicious.Whenthishappens,thefirewallwillshutoffthatstreamofcontent,leadingtoa503Error. ChecktheLogs Nearlyeverywebapplicationwillkeepsomeformofserver-sidelogs,suchasApplicationLogsandServerLogs. Applicationlogs:Theselogscontainthehistoryofwhattheapplicationdid.Thisusuallyincludesrequestedpages,connectedservers,databaseresults,andsoforth. Serverlogs:Theselogsarerelatedtotheactualhardwarerunningtheapplicationandwilloftenprovidedetailsaboutthehealthandstatusofallconnectedservices,orjusttheserveritself.Google“logs[PLATFORM_NAME]”ifyou’reusingaCMS,or“logs[PROGRAMMING_LANGUAGE]”and“logs[OPERATING_SYSTEM]”ifyou’rerunningacustomapplicationtogetmoreinformationonfindingthelogsinquestion. ApplicationCodeorScriptBugs Ifallelsefails,checkyourcode.Abugcouldbecausingthe503ServiceUnavailableError.Trydiagnosingtheissuebymanuallydebuggingyourapplicationandparsingthroughapplicationandserverlogs.Ideally,makeacopyoftheentireapplicationtoalocaldevelopmentmachineandperformastep-by-stepdebugprocess.Thiswillallowyoutorecreatetheexactscenarioinwhichthe503ServiceUnavailableError occurred.Onceyouknowwhytheerroroccurred,youcangoaboutfixingit.  A503ServiceUnavailableError withinyourwebapplicationisastrongindicationthatyoumayneedanerrormanagementtool.That’swhereAirbrakecomesin. AirbrakeError&PerformanceMonitoringsoftwareprovidesreal-timeerrormonitoringandautomaticexceptionreportingforallyourdevelopmentprojects.Airbrake’sdashboardsensureyoureceiveround-the-clockstatusupdatesonyourapplication’shealthanderrorrates. Plus,Airbrakemakesiteasytocustomizeexceptionparameterswhilegivingyoucompletecontroloftheactiveerrorfiltersystem,soyouonlygathertheerrorsthatmattermost. CheckoutAirbrake’serrormonitoringsoftwaretodayandseeforyourselfwhysomanyoftheworld’sbestengineeringteamsuseAirbraketorevolutionizetheirexceptionhandlingpractices! Note:WepublishedthispostinNovember2017andrecentlyupdateditinJanuary2022. MonitorYourAppFreefor30Days DiscoverthepowerofAirbrakebystartingafree30-daytrialofAirbrake.Quicksign-up,nocreditcardrequired.Getstarted. FooterFeaturedBlogPosts Languages TryAirbrakeFREEfor30-Days Resources ContactUs 98SanJacintoBlvd,Suite1300 Austin,TX78701 +1888-415-6442 [email protected] GitHubLinkedInTwitterYouTube



請為這篇文章評分?