HTTP Error 503 Service Unavailable Explained - freeCodeCamp
文章推薦指數: 80 %
A 503 Service Unavailable error means that the page or resource is unavailable. There are many reasons why a server might return a 503 error ... Search Submityoursearchquery Forum Donate KrisKoishigawa Errorshappen–there'ssomeunexpectedmaintenance,abugthatwentunnoticed,orapagegoesviralandthefloodofconnectionstaketheserverdown.Ifyou'vebeenonlineforanyamountoftime,nodoubtyou'veseenthesomewhatvague503ServiceUnavailableerror.Inthisarticlewe'llgooverHTTPstatuscodes,whatthe503errormeans,andsomepossiblewaystosolveit–bothforasiteyou'retryingtovisitandforyourownsite.AnoverviewofHTTPstatuscodesServersthathostwebpageslistenforrequestsfromwebbrowsersordevices,alsoknownasclients.Theserverthenusesabunchofdifferentstatuscodestocommunicateback.Thesestatuscodesareorganizedintodifferentclasses,whichisindicatedbythefirstnumberofthestatuscode:1xx:Information–theserverisstillprocessingtherequest2xx:Success–therequestsucceededandtheserverrespondswiththepageorresource3xx:Redirection–thepageorresourcehasmovedandserverwillrespondwithitsnewlocation4xx:Clienterror–thereisanerrorintherequestfromthebrowserordevice5xx:Servererror–thereisanerrorwiththeserverThelasttwodigitsofeachHTTPstatuscoderepresentamorespecificstatusforeachclass.Forexample,301meansthatapageorresourcehasmovedpermanently,while302meansthemoveistemporary.CheckoutthispageforalistofcommonHTTPstatuscodesandtheirmeaning:https://en.wikipedia.org/wiki/List_of_HTTP_status_codesMoststatuscodesgobytotallyunnoticed,whichisfinebecauseitmeanseverythingisworking.It'sonlywhenyougettothe4xx-5xxrangethatyoumightnoticeastatuscodebecauseyou'llseeapagelikethis:Atypical503errorpage–Source:StackOverflowNowthatyouhaveabasicunderstandingofHTTPstatuscodes,let'sdigabitdeeperintothe503ServiceUnavailableerror.Whatdoesthe503errorcodemean?Asmentionedabove,5xxstatuscodesmeanthere'saproblemwiththeserveritself.A503ServiceUnavailableerrormeansthatthepageorresourceisunavailable.Therearemanyreasonswhyaservermightreturna503error,butsomecommonreasonsaremaintenance,abugintheserver'scode,orasuddenspikeintrafficthatcausestheservertobecomeoverwhelmed.Themessagethat'ssentwiththe503errorcanvarydependingonserverit'scomingfrom,butherearesomeofthecommononesyou'llsee:-503ServiceUnavailable-503ServiceTemporarilyUnavailable-HTTPServerError503-HTTPError503-Error503ServiceUnavailable-Theserveristemporarilyunabletoserviceyourrequestduetomaintenancedowntimeorcapacityproblems.Pleasetryagainlater.SourceWhateverthereasonforthe503error,it'susuallytemporary–theserverwillrestart,trafficwilldiedown,andtheissuewillresolveitself.Howtosolvethe503StatusUnavailableerrorWhentryingtosolvea503error,therearetwogeneralcamps.Thefirstiswhereyou'reanenduser,andyou'retryingtovisitasitethatyoudon'town.Inthesecond,youownthesite,andit'sthrowing503errorstopeoplewhoaretryingtovisit.Themethodtosolve503errorsisdifferentdependingonwhichgroupyoufallinto.Let'stakealookatsomethingsyoucandoasanenduserifyouseea503error.Howtosolvea503StatusUnavailableerrorasanenduserSince5xxstatuscodesmeanthattheerrorisontheserver-side,thereisn'talotyoucandodirectly.Eventhough503errorsareusuallytemporary,therearesomethingsyoucandowhileyouwait.#1:RefreshthepageSometimestheerrorissotemporarythatasimplerefreshisallittakes.Withthepageopen,justpressCtrl-RonWindowsandLinux,orCmd-RonmacOStorefreshthepage.#2:SeeifthepageisdownforotherpeopleThenextthingyoucandoisuseaservicelikeIsItDownRightNow?orDownForEveryoneOrJustMetoseeifotherpeoplearegettingthesameerror.JustgotoeitherofthosesitesandenterintheURLforthepageyou'retryingtovisit.TheservicewillpingtheURLyouenteredtoseeifitgetsaresponse.Thenit'llshowyousomecoolstatsandgraphsaboutthepage:CheckingfreeCodeCamponIsItDownRightNow?Ifyouscrolldownabityou'llseesomecommentsfromotherpeople.Oftenpeoplewillgivetheirgenerallocationandotherdata,sothiscanbeagoodwaytodetermineiftheerrorisjustaffectingcertainregionsorspecificdevices.#3:RestartyourrouterSometimestheissuehastodowithaDNSserverfailure.DNSstandsforDomainNameSystem,andtheybasicallyactastranslatorsbetweenIPaddressesandhumanreadableURLs.Forexample,youcanvisitGooglebyenteringitslongIPaddressdirectly(172.217.25.206),oryoucanjustenterintheURL,www.google.com.It'saDNS,oftenhostedonaserver,thathandlesallthatbehindthescenes.Allofthatistosay,manyrouterscacheresponsesfromDNSservers(www.google.com<==>172.217.25.206).Butsometimesthiscachecangetcorruptedandcauseerrors.Aneasywaytoresetor"flush"thecacheistorestartyourrouter.Justunplugyourrouterforabout5seconds,thenplugitbackinagain.Itshouldrestartafteraminuteandallofyourdevicesshouldreconnectautomatically.Oncetheydo,tryvisitingthesiteagain.Howtosolvea503StatusUnavailableerrorasthesite'sownerIfyouaretheowner/developerofthesitethat'sreturning503errors,there'sabitmoreyoucandotodiagnoseandresolvetheissue.Herearesomegeneraltipstogetyoustarted:#1:RestarttheserverDevelopmentistough–evenasimplestaticpagecanhavesomanymovingpartsthatitcanbedifficulttopindownwhat'scausingthe503error.Sometimesthebestthingtodoistorestarttheserverandseeifthatfixestheissue.Source:imgflipTheexactmethodofrestartingyourservercanvary,butusuallyyoucanaccessitfromyourprovider'sdashboardorbySSH'ingintotheserverandrunningarestartcommand.Theservershouldrestartafteracoupleofminutes.Ifyou'veconfiguredeverythingtorunautomaticallyonboot,youcanvisityoursiteandseeifit'sworking.#2:ChecktheserverlogsThenextthingtodoischeckthelogs.Thelocationoftheserverlogscanvarydependingonwhatserviceyou'rerunning,butthey'reoftenfoundin/var/log/....Takealookaroundthatdirectoryandseeifyoucanfindanything.Ifnot,checkthemanualforyourprogramsbyrunningmanprogram_name.#3:Checkifthere'songoingautomatedmaintenanceSomeserviceprovidersofferautomatedpackageupdatesandmaintenance.Normallythisisagoodthing–theyusuallyoccurduringdowntime,andhelpmakesureeverythingisup-to-date.Occasionally503errorsareduetothesescheduledmaintenancesessions.Forexample,somehostingprovidersthatspecializeinWordPresshostingautomaticallyupdateWPwheneverthere'sanewrelease.WordPressautomaticallyreturnsa503ServiceUnavailableerrorwheneverit'sbeingupdated.Checkwithyourserviceproviderstoseeifthe503errorisbeingcausedbyscheduledmaintenance.#4:Checkyourserver'sfirewallsettingsSometimes503ServiceUnavailableerrorsarecausebyamisconfiguredfirewallwhereconnectionscangetthrough,butfailtogetbackouttotheclient.YourfirewallmightalsoneedspecialsettingsforaCDN,wheremultipleconnectionsfromasmallhandfulofIPaddressesmightbemisinterpretedasaDDoSattack.Theexactmethodofadjustingyourfirewall'ssettingsdependsonalotoffactors.Takealookatyourpipelineandyourserviceprovider'sdashboardstoseewhereyoucanconfigurethefirewall.#5:CheckthecodeBugs,likeerrors,happen.Tryasyoumight,it'simpossibletocatchthemall.Occasionallyonemightslipthroughandcausea503error.Ifyou'vetriedeverythingelseandyoursiteisstillshowinga503ServiceUnavailableerror,thecausemightbesomewhereinthecode.Checkanyserver-sidecode,andpayspecialattentiontoanythinghavingtodowithregularexpressions–asmallregexbugiswhatcausedahugespikeinCPUusage,rollingoutages,andaboutthreedaysofpanicforusatfreeCodeCamp.Hopefullyyou'llbeabletotrackdowntheculprit,deployafix,andeverythingwillbebacktonormal.InsummaryThatshouldbeeverythingyouneedtoknowabout503ServiceUnavailableerrors.Whilethere'susuallynotmuchyoucandowhenyouseea503error,hopefullysomeofthesestepswillhelpthenexttimeyouencounterone.Staysafe,andhappyrefreshing-until-it-works:) KrisKoishigawa Readmorepostsbythisauthor. Ifyoureadthisfar,tweettotheauthortoshowthemyoucare.Tweetathanks Learntocodeforfree.freeCodeCamp'sopensourcecurriculumhashelpedmorethan40,000peoplegetjobsasdevelopers.Getstarted
延伸文章資訊
- 1How to Fix the HTTP Error 503 Service Unavailable - Kinsta
The 503 (Service Unavailable) status code indicates that the server is currently unable to handle...
- 2How to fix HTTP error 503: The service is unavailable - Windows Report
- 3How to Fix a 503 Service Unavailable Error Message - Lifewire
The 503 Service Unavailable error is an HTTP status code that means the website's server is not a...
- 4異常Failed to load resource: the server ... - 程序员大本营
異常Failed to load resource: the server responded with a status of 503 (Service Unavailable),程序员大本营...
- 5HTTP Error 503 Service Unavailable Explained - freeCodeCamp