EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials SQL Tutorial SQL Port
 

SQL Port

Updated March 8, 2023

SQL Port

 

 

Introduction of SQL Port

In networking, a port is a docking endpoint through which communication is established between the server and client and information flows from a program in the user’s computer to servers on the internet. In SQL also, we have multiple types of database engines such as SQL SERVER, POSTGRESQL, MYSQL etc. which communicate through ports. When a port number is used in combination with an IP address, it determines the direction of flow of information. These ports are part of the Transport Layer and are usually of two types TCP(Transmission Control Protocol) and User Datagram Protocol(UDP). Each port in the SQL database engine has a unique service to perform. For example, TCP 1433 is the default port number in SQL Server, and it is used for managing SQL instances over the network. While PostgreSQL uses TCP 5432 to perform the same task.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

You must be wondering that I get it that there are designated ports for communication, but who gets to decide which service will get what port number? These port numbers are provided to services by Internet Assigned Numbers Authority (IANA). It is also responsible for managing the uses of these ports in the networking world.

In this article, we will attempt to illustrate how you can check the port number on which your SQL database engine is running, how it can be changed, and a few other things. For this article, we have written examples for PostgreSQL and SQL Server. But once you get the hang of it in any database engine, it’s quite intuitive in others.

Examples of SQL Port

Following are the examples are given below:

Example #1

How to find the port number to which the PostgreSQL database server is listening and change it to a new port number?

We can find out the port number and other details of the port to which the server is listening using a SELECT statement on the pg_settings table as shown below.

SELECT name, setting, category , short_desc
FROM pg_settings
WHERE name = 'port';

SQL Port-1.1

In this example, we have just fetched the port number, category, and description from the table. You can use SELECT * instead and fetch all the details. Now, observe the port number ‘5432’ and the short_desc corresponding to it. TCP port 5432 is the default to which the server listens to. For the curious ones, you can find more details on networking in SQL database server from the postmaster file or use the query given below.

select *
from pg_settings
where context = 'postmaster';

SQL Port-1.2

You will set some output, as shown in the image above.

Changing Port Number to A Different Port Number.

Step 1: Open SQL shell and write the following commands in the shell.

locate postgresql.conf

SQL Port-1.3

Step 2: The last step gave you the current port number. Next, to change it, write the following commands in the shell and restart your postgres server.

port = 5433
listen_addresses='*'

The above mentioned command will change the port number to ‘5433’ corresponding to all the IP addresses. You can get specific here by mentioning a specific IP address instead of ‘*’.

Example #2

How to find the port number to which the MS SQL server is listening and how to change it?

In SQL server, we have SQL Server configuration manager where we have all the configuration details saved. If you want to see what port number your database server is listening to follow the following steps then.

Step 1: Open SQL Server configuration manager. (If you are not able to find it directly look for it in the search tab)

 Step 2: Once you have opened your SQL Server configuration manager, open SQL Server Network Configuration as shown in the image below.

SQL Port-1.4

Step 3: After selecting the SQL Server Network Configuration, click on Protocols for SQLExpress. A menu as shown in the image below will appear. Select TCP/IP from it. (If it’s not already enabled, enable it.)

SQL Port-1.5

Step 4: When you will select from the Protocols menu, the TCP/IP dialog box as shown below will appear. There is no port number mentioned in this case because it is running on dynamic TCP. TCP Dynamic Port = ‘0’ means that your server is listening on dynamically allocated port numbers. TCP Port is the field that gives us the desired port number.

 Output-1.6

Step 5: If you wish to change the TCP port number then provide a new port number in the blank space corresponding to IP address 127.0.0.1, this corresponds to your localhost. You may make a change in IPALL if you want to change it for all the addresses.

Output-1.7

Step 6: Once you are done with making all the necessary changes, click on Ok. An alert pop-up, as shown below, will appear. Click on OK and restart your SQL Server.

Output-1.8

And you are done changing the port number.

Conclusion

In this post, we have covered how to find the port number to which the SQL database server is listening to and have also learned to change it to a specific port number. A SQL port is basically a TCP port that acts as the endpoint of communication between your local computer and database server on the network.

Recommended Articles

We hope that this EDUCBA information on “SQL Port” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

  1. SQL DECODE()
  2. MySQL GROUP BY
  3. SQL Users
  4. MySQL Interval

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW