title: How do I make Heroku to listen to multiple ports?
body: <p>I am trying to host my application on Heroku but I get the below error from the logs:</p>
  <pre><code>Error: listen EADDRINUSE: address already in use :::27427
  </code></pre>
  <p>Apollo Server:</p>
  <pre><code>const { ApolloServer } = require(&quot;apollo-server&quot;);
  
  const typeDefs = require(&quot;./server/graphql/typedefs&quot;);
  const resolvers = require(&quot;./server/graphql/resolvers&quot;);
  
  const server = new ApolloServer({ typeDefs, resolvers });
  
  server.listen({ port: process.env.PORT || 4000 }).then(({ url }) =&gt; {
      console.log(` Apollo Server ready at ${url} `);
  });
  
  // Express server
  const express = require(&quot;express&quot;);
  const app = express();
  const cors = require(&quot;cors&quot;);
  app.use(express.json());
  app.use(
      cors({
          origin: &quot;http://localhost:3000&quot;,
      })
  );
  
  const stripe = require(&quot;stripe&quot;)(&quot;sk_test_51Kv9RvGa9sOwxIsovOU0IliCRkL4Qrvi0F1dis4M4Slk1TvEzcuYrx4zBuLZH1iU76ygkDtoXA3Gky6RJEdaBTDa00fDh2Oh1g&quot;);
  
  app.post(&quot;/create-checkout-session&quot;, async (req, res) =&gt; {
      try {
          const session = await stripe.checkout.sessions.create({
              customer_email: req.body.email ? req.body.email : undefined,
              payment_method_types: [&quot;card&quot;],
              mode: &quot;payment&quot;,
              line_items: req.body.items.map((item) =&gt; {
                  return {
                      price_data: {
                          currency: &quot;usd&quot;,
                          product_data: {
                              name: item.name,
                          },
                          unit_amount: item.price * 100,
                      },
                      quantity: item.quantity,
                  };
              }),
              success_url: `http://localhost:3000/paymentsuccess/${req.body.secret}`,
              cancel_url: `http://localhost:3000/paymentfailed/${req.body.secret}`,
          });
          res.json({ url: session.url });
      } catch (e) {
          res.status(500).json({ error: e.message });
      }
  });
  
  app.listen({ port: process.env.PORT || 5001 }, () =&gt; {
      console.log(&quot; Express server ready at http://localhost:5001 &quot;);
  });
  </code></pre>
  <p>I think the issue is that I am using both Apollo Server and Express Server in my app. But I need the express for my stripe application. Is there a way so that Heroku can listen to both of my ports?</p>