Apache, IIS and 502 proxy error

I have some servers in my network. There is one public Apache server that proxies requests to these servers. These servers are not directly visible from internet. Some of these servers run IIS and ASP.NET web applications. When accessing these servers through internet then sometimes Apache reports a problem: 502 proxy error.

After some digging in internet I found out what’s going on between Apache and IIS. There is very informative bug report in Apache issue tracker – Bug 37770 – proxy: error reading status line from remote server (null). Comment #17 states reason of error as follows:

The problem also only occurs for us when we use an IIS backend device, with an apache its ok. From a tcpdump the only diff I can see between the two sessions is that the IIS closes the connection when the keep-alive time out is reached with a TCP RST packet, while the apache does a Fin/Ack handshake. When IIS sends this RST packet the next request to the mod_proxy device that’s hits the worker with the RST connection returns the 502 error msg.

So, there is some misunderstandings between Apache proxy stuff and IIS. Although some guys suggest to use very long timeouts and hacks to Apache source code there is very simple fix that works very well for me. Make sure you have mod_env enabled and add these lines to Apache configuration file.

SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1

After restarting Apache server the communication between Apache and IIS should work fine. After these modifications I have seen no error 502 anymore.

Gunnar Peipman

Gunnar Peipman is ASP.NET, Azure and SharePoint fan, Estonian Microsoft user group leader, blogger, conference speaker, teacher, and tech maniac. Since 2008 he is Microsoft MVP specialized on ASP.NET.

    86 thoughts on “Apache, IIS and 502 proxy error

    • February 11, 2009 at 6:15 pm
      Permalink

      This post is very timely. I just set up dev environments for me and my co-workers at my job, and this issue has been frustrating us. Many thanks.

    • August 11, 2009 at 10:33 am
      Permalink

      Nice blog
      I am facing same problem. I have done the above mentioned changes SetEnv. But still getting the same error.I am using apache 2.2.3

    • August 26, 2009 at 11:17 am
      Permalink

      This solution worked for me, thanks for posting it

    • September 3, 2009 at 11:03 am
      Permalink

      Good Solution.. Worked for me..

    • September 21, 2009 at 9:19 am
      Permalink

      Firstly, I would like to know the impact of 502 error. When the apache act as proxy reported 502, how the apache will assume the status of IIS servers?

      On other hand, the two setenv will fallback to httpd/1.0 without keepalive. Does it may increaes the TCP sockets needed to be opened as no more keepalive?

      This will increase the loading for the IIS server.

    • May 14, 2010 at 7:27 am
      Permalink

      I am getting this error in two scenarious after this env setting is done,
      if the request that is made from the browser is time taking/bigger size data as a result.
      and observed if number of simultaneous requests are in the range of 5-10

      Please help me

    • May 10, 2011 at 11:40 am
      Permalink

      Althu, this was written in 2009, but helped me last day. Was having same issue and was unable to find root couse. This helps. Thanks a lot and keep up the good things.

    • June 17, 2011 at 7:57 pm
      Permalink

      Great! This is exactly what I was looking for and it works! Thanks!

    • October 10, 2011 at 11:06 am
      Permalink

      I had a similar problem and resorted to turning of HTTP keep-alive among the common response headers in IIS. Works for both IIS6 and IIS7.

    • November 22, 2011 at 4:42 am
      Permalink

      Checked out your Gateway IP, Same problem did hurt me also on inspection i found that i did’t give my Gateway IP to my LAN Card.

    • December 8, 2011 at 10:03 am
      Permalink

      After upgrading my IIS backend from Windows 2003/IIS6 to Windows 2008/IIS7 I suddenly got 502 errors. Thanks to this post I was able to sort out the issue, thanks a lot!!!

    • September 5, 2012 at 6:09 am
      Permalink

      Thanks DigiMortal, this solved a very big problem for me!

      / Jakob

    • Pingback:Fix Apache Error 502 Errors - Windows XP, Vista, 7, 8

    • Pingback:How To Fix Apache Error Reading From Remote Server in Windows

    • April 5, 2025 at 10:13 pm
      Permalink

      Hello, after reading this amazing paragraph i am too happy to share my know-how here with mates.

    • April 6, 2025 at 1:34 pm
      Permalink

      After I initially commented I appear to have clicked the -Notify
      me when new comments are added- checkbox and from now on every time a comment
      is added I recieve four emails with the exact same comment.
      Is there a way you can remove me from that service? Cheers!

      My web page: https://www.cucumber7.com/

    • April 27, 2025 at 4:34 am
      Permalink

      My programmer is trying to persuade me to move
      to .net from PHP. I have always disliked the idea because of
      the costs. But he’s tryiong none the less. I’ve been using WordPress on various
      websites for about a year and am concerned about switching to another
      platform. I have heard very good things about blogengine.net.
      Is there a way I can transfer all my wordpress
      posts into it? Any kind of help would be really appreciated!

    • April 28, 2025 at 8:34 pm
      Permalink

      I’m no longer sure where you’re getting your info, however
      great topic. I needs to spend a while learning more or understanding more.
      Thank you for magnificent info I used to be on the
      lookout for this info for my mission.

    • April 29, 2025 at 12:13 pm
      Permalink

      Very nice post. I just stumbled upon your weblog and wished to
      say that I have truly enjoyed surfing around your blog posts.

      After all I’ll be subscribing to your rss feed and I hope
      you write again soon!

      my site … Engine Performance

    • April 30, 2025 at 7:34 pm
      Permalink

      Very good site you hаve heee but I waѕ curious if you knew of any community forums that cover the same topics discussed here?
      I’d really love to bbe a part of group where I can get
      feed-back frⲟm other excperienced individuals that share the same interest.
      If you have anny suggestions, please let me know.
      Bless you!

      Feel free to visit my page unblocked games 66

    • May 13, 2025 at 1:58 pm
      Permalink

      I have been surfing online more than 3 hours today, yet I never found any interesting article like yours.

      It is pretty worth enough for me. In my view, if all website
      owners and bloggers made good content as you did,
      the web will be a lot more useful than ever before.

      My web page :: Camshaft Timing Control

    • May 14, 2025 at 4:26 pm
      Permalink

      Useful info. Lucky me I discovered your website by chance, and
      I am shocked why this coincidence did not took place earlier!
      I bookmarked it.

    • May 16, 2025 at 1:26 pm
      Permalink

      Thank you a bunch for sharing this with all folks you
      actually recognize what you are talking about! Bookmarked.

      Kindly also talk over with my website =). We could have a hyperlink
      alternate arrangement between us

    • May 22, 2025 at 2:44 pm
      Permalink

      you’re in reality a just right webmaster. The website loading speed is amazing.
      It sort of feels that you are doing any distinctive trick.
      Furthermore, The contents are masterwork. you have performed a great process on this topic!

    • May 23, 2025 at 4:45 am
      Permalink

      excellent points altogether, you simply won a new reader.

      What might you suggest in regards to your post that you made a few
      days ago? Any positive?

    • May 23, 2025 at 4:49 pm
      Permalink

      Een doordacht en prikkelend artikel. Ik heb hhet gedeeld op X (voorheen Twitter)
      om te helpen de boodschap te verspreidenom het onder de aandacht te brengenom het te promotenom
      de bekendheid te vergrotenom het te dele meet anderen.

    • May 29, 2025 at 11:54 pm
      Permalink

      What’s up colleagues, nice post and fastidious urging commented here, I am in fact enjoying by these.

    • June 5, 2025 at 4:38 am
      Permalink

      Unquestionably believe that that you said. Your favourite justification seemed to be at
      the net the simplest factor to remember of. I say to you, I definitely get
      irked while other folks think about concerns that they just
      do not recognize about. You managed to hit the nail upon the highest and outlined out the whole
      thing with no need side effect , other people could take
      a signal. Will likely be again to get more. Thanks

    • June 9, 2025 at 5:04 pm
      Permalink

      It’s perfect time to make some plans for the future and it is time to be happy.

      I’ve read this post and if I could I want to suggest you some interesting things or tips.

      Perhaps you can write next articles referring to
      this article. I wish to read even more things about it!

    • June 17, 2025 at 8:13 pm
      Permalink

      The Private Instagram Viewer is a simple tool meant to allow you anonymously investigate public Instagram profiles without
      logging into your own account. Whether you’re eager virtually a username,
      want to look someones profile portray in full
      size, or check out their bio and public posts, this tool makes it fast and private.

    • June 24, 2025 at 3:17 pm
      Permalink

      Hmm it looks like your site ate my first comment (it
      was extremely long) so I guess I’ll just sum it up what I submitted and
      say, I’m thoroughly enjoying your blog. I as well am an aspiring blog blogger but I’m still new to everything.
      Do you have any points for first-time blog writers?
      I’d certainly appreciate it.

    • June 26, 2025 at 5:30 pm
      Permalink

      Hi, I believe your website might be having internet browser
      compatibility problems. Whenever I take a look at your blog in Safari,
      it looks fine however when opening in IE, it has some overlapping issues.
      I merely wanted to provide you with a quick heads up!
      Apart from that, wonderful site!

    • July 2, 2025 at 6:07 am
      Permalink

      Definitely believe that which you stated. Your favorite reason seemed to be on the web the simplest factor to take into account of.
      I say to you, I definitely get annoyed at the same time as other people think about
      worries that they just do not understand about. You controlled to hit the
      nail upon the top as smartly as defined out the entire
      thing without having side effect , people can take a signal.
      Will likely be again to get more. Thanks

    • July 3, 2025 at 7:36 pm
      Permalink

      Excellent read! It answered my questions. Bookmarking this for later.

      If anyone’s interested, feel free to visitZysk z NV
      Casino. Thanks again!

    • July 5, 2025 at 12:57 am
      Permalink

      I love digital stream because that’s always there when me want
      this. AM drink? Jazz out of France. Late-night sessions?
      That downtempo synth via the city. Me don’t have to
      dig up mixes nor skip songs—just smash go then allow
      everything flow. It’s similar to someone who forever gets
      which I crave to listen to.

      There is a mood special when connecting with a real-time channel,
      feeling someone else is listening at the same time.
      This seems honest. I came across channels that play classic
      rap, USSR-style funk, also bizarre night talk shows based in Canada.
      Internet streaming is more than music—this is an endless space streaming
      alongside my day.

      Stop by my web page: Online radio

    • July 6, 2025 at 9:54 pm
      Permalink

      Thanks for sharing your thoughts. I really appreciate your efforts and I am waiting for your next write ups thanks once again.

    • July 17, 2025 at 10:57 pm
      Permalink

      Ridiculous story there. What happened after? Take care!

    • July 18, 2025 at 2:27 pm
      Permalink

      I know this if off topic but I’m looking into starting my own blog and was wondering what all is
      needed to get set up? I’m assuming having a blog like
      yours would cost a pretty penny? I’m not very internet
      savvy so I’m not 100% positive. Any suggestions or advice would be greatly appreciated.
      Many thanks

    • July 26, 2025 at 7:38 am
      Permalink

      Truly when someone doesn’t know then its up to other visitors that they will assist, so here it takes place.|

    • July 31, 2025 at 2:37 am
      Permalink

      I’ve been browsing online more than 3 hours nowadays, but I never discovered any attention-grabbing article like yours. It’s beautiful value sufficient for me. Personally, if all website owners and bloggers made excellent content material as you probably did, the net will likely be a lot more helpful than ever before.

    • August 1, 2025 at 1:48 am
      Permalink

      Hey
      Stoped by to tell you how interesting your site is!

      I also have an page about 유출출사
      feel free to visit and give me some likes
      Thank you!

    • August 5, 2025 at 8:52 am
      Permalink

      Many businesses look for appealing visual content for platforms like YouTube and Instagram.

      My web blog work from home social media jobs india [git.fofpower.cn]

    • August 7, 2025 at 5:09 am
      Permalink

      Wow, that’s what I was exploring for, what a data!
      existing here at this web site, thanks admin of this web site.

    • August 11, 2025 at 2:44 pm
      Permalink

      I’m not sure where you’re getting your information, but good topic.

      I needs to spend some time learninbg much more or understanding more.

      Thanks for magnificent informatioon I wwas looking for this info for my mission.

    • August 12, 2025 at 5:22 pm
      Permalink

      Hello
      Stoped by to say how interesting your post is!
      I have a site about 유출출사
      come visit and give me some feedback
      Thank!

    • August 15, 2025 at 11:47 pm
      Permalink

      Hi Dear, are you really visiting this website daily, if so afterward
      you will absolutely take pleasant knowledge.

    • August 29, 2025 at 12:17 pm
      Permalink

      Thanks , I’ve just been looking for info approximately
      this subject for a while and yours is the greatest I have found out so far.
      However, what in regards to the bottom line? Are you certain about the supply?

    • September 3, 2025 at 8:23 am
      Permalink

      ค่าย PG เกมสล็อตแตกง่าย!
      ทำกำไรได้จริง แค่ปลายนิ้วก็รวยได้!,หมดปัญหาเกมสล็อตทำเงินยาก!

      ลอง PGSLOT สิ! สล็อตแตกจริง รับทรัพย์เต็มๆ,โอกาสทองมาแล้ว!
      PGSLOT แจกหนัก ทุกคนที่สมัคร,ไม่ต้องมีทุนเยอะก็เล่นได้!
      PGSLOT เกมสล็อต pgยอดนิยม กำไรงาม จ่ายเต็ม,เข้าเล่น PGSLOT ตอนนี้!
      โกยกำไรมหาศาล ทันที!,ที่สุดของความบันเทิงและรางวัลใหญ่ ต้องที่ PGSLOT เท่านั้น!,
      พีจีสล็อต: มีคืนยอดเสียให้!
      คุ้มกว่านี้ไม่มีอีกแล้ว รับเงินคืนไปเลย!,พิเศษสำหรับสมาชิกใหม่!
      PGSLOT แจกโบนัสแรกเข้า รับเองง่ายๆ,พลาดไม่ได้!
      พีจีสล็อต โปรโมชั่นเด็ดประจำสัปดาห์ แจกโบนัสเพียบ,ฝากน้อยได้เยอะกับ PGSLOT!
      สิทธิพิเศษมากมาย รอคุณอยู่เพียบ,
      พีจีสล็อต ชวนเพื่อนมาเล่น รับค่าคอมมิชชั่นสูงที่สุดในไทย!,คุ้มยิ่งกว่าคุ้ม!

      เดิมพัน PGSLOT ไม่มีผิดหวัง โปรโมชั่นเยอะ โบนัสแยะ,
      สนุกกับ PGSLOT ได้ทุกที่!

      ใช้งานง่ายทุกอุปกรณ์ ครบครันในหนึ่งเดียว,ปลอดภัยหายห่วง!
      PGSLOT เว็บตรง ไม่ผ่านเอเย่นต์ ระบบออโต้ ใน 30 วินาที,พร้อมดูแลตลอด 24 ชั่วโมง!
      ทีมงานคุณภาพ ใส่ใจทุกปัญหา,PGSLOT เว็บสล็อตอันดับ 1 ที่นักเดิมพันไว้วางใจ มั่นคงและเชื่อถือได้,เข้าเล่น PGSLOT ได้ทันที เล่นผ่านเว็บบราวเซอร์ ง่ายๆ แค่คลิก!,ระบบลื่นไหล ไม่มีสะดุด!
      พีจีสล็อต มอบประสบการณ์สุดยอด,

      ยืนยันจากผู้เล่นจริง!
      พีจีสล็อต โบนัสเข้าตลอด เล่นแล้วรวย!,ประทับใจบริการ PGSLOT มาก ไม่ต้องรอนานเลย ประทับใจแน่นอน!,นี่แหละสล็อตที่ตามหา!

      พีจีสล็อต ภาพสวย เสียงคมชัด โบนัสแตกบ่อยจริง!,
      จากใจคนเคยเล่น! พีจีสล็อต
      ตรงใจทุกความต้องการ สุดยอดจริงๆ!,ใครยังไม่ลอง PGSLOT ถือว่าพลาดมาก!
      ช่องทางรวยง่ายๆ รอคุณอยู่,สุดยอดเว็บสล็อตแห่งปี!

      PGSLOT เกมแตกง่าย เพลินตลอด!

    • September 5, 2025 at 10:59 am
      Permalink

      Very quickly this web page will be famous amid all blogging users, due
      to it’s nice articles or reviews

    • September 6, 2025 at 1:15 am
      Permalink

      obviously like your web-site but you have to check the spelling on several of your posts. A number of them are rife with spelling issues and I find it very troublesome to tell the truth nevertheless I’ll definitely come back again.

    • September 7, 2025 at 5:38 am
      Permalink

      I was curious if you ever considered changing the layout of your blog?
      Its very well written; I love what youve got to say.
      But maybe you could a little more in the way of content so people could connect
      with it better. Youve got an awful lot of text for only having one or 2 images.
      Maybe you could space it out better?

    • September 8, 2025 at 10:12 pm
      Permalink

      No matter if some one searches for his required thing, therefore he/she wishes to be available that in detail,
      therefore that thing is maintained over here.

    Leave a Reply

    Your email address will not be published. Required fields are marked *