Cannot start the oauth redirect server on port 1717.

302    Asked by Dadhijaraj in Salesforce , Asked on May 24, 2024

 I am a software developer and I am currently working on a particular task that is related to the integration of OAuth into a web-based application. During the time of testing, I encountered an issue where I could not start the Oauth redirect server in port 1717. How can I troubleshoot and resolve the issue? 

Answered by Deepak Mistry

 In the context of Salesforce, here are the steps given of how you can approach troubleshooting and resolve the issue of not being able to start or begin the OAuth redirect server on port 1717:-

Checking for the port availability

You can use a command line tool such as “netstart” to check if port 1717 is already in use by another application. If it is, you can try to choose a different port or stop the conflicting application.

Updating the OAuth server configuration

You should try to ensure that the OAuth server configuration specifies port 1717.

Checking the firewall setting

Try to make sure that your firewall setting allows inbound and outbound traffic on the particular port of Port 1717. You should adjust the rules of the firewall if needed.

Restart the services

Sometimes, the problem can be solved by just restarting your development process or environment.

Use a proxy or tunneling service

If port 1717 is blocked by your network or ISP, you should try to consider using a proxy server or a tunneling service like ngrok to expose your local server to the internet.

Here are the coding example or structures given for above steps:-

Const express = require(‘express’);
Const app = express();
Const http = require(‘http’);
Const server = http.createServer(app);
Const PORT = 1717;
// Check if port 1717 is already in use
Server.listen(PORT);
Server.on(‘error’, (err) => {
    If (err.code === ‘EADDRINUSE’) {
        Console.log(`Port ${PORT} is already in use. Please choose a different port.`);
    } else {
        Console.error(‘Server error:’, err);
    }
    Process.exit(1); // Exit the process
});
Server.on(‘listening’, () => {
    Console.log(`OAuth server running on port ${PORT}`);
});
// OAuth callback route
App.get(‘/oauth/callback’, (req, res) => {
    // OAuth callback logic
    Res.send(‘OAuth callback received’);
});
// Check firewall settings
// Ensure that inbound and outbound traffic on port 1717 is allowed
// Debugging and logging
// Implement detailed logging and debugging as needed
// Example ngrok tunneling
// ngrok http 1717
// Start the server
// app.listen(PORT, () => {
// console.log(`OAuth server running on port ${PORT}`);
// });
Here are the Python based example given:-
From flask import Flask
App = Flask(__name__)
# OAuth callback route
@app.route(‘/oauth/callback’)
Def oauth_callback():
    # OAuth callback logic
    Return ‘OAuth callback received’
If __name__ == ‘__main__’:
    Try:
        # Attempt to run the Flask app on port 1717
        App.run(port=1717)
    Except OSError as e:
        If e.errno == 98:
            Print(“Port 1717 is already in use. Please choose a different port.”)
        Else:
            Print(f”Error: {e}”)

Here is the HTML based example given below:-




    <meta</span> charset=”UTF-8”>

    <meta</span> name=”viewport” content=”width=device-width, initial-scale=1.0”>

    Form Submission



    Submit Form

   


        Name:

       


        Email:

       


        Message:

       


       

   






Your Answer

Interviews

Parent Categories