Default Postgres Port

0
183
Default Postgres Port

You can manage your PostgreSQL database through the web interface, but you must use the default progress port. PostgreSQL is a fast database that is also known for its power and support for JSON file formats. However, in order to configure the PostgreSQL Database service on localhost, you may need to use its default port of 5432.

This port, on the other hand, can be easily changed from the Postgresql.conf configuration file, which serves as the database’s primary configuration file. 5432 is a TCP port for the PostgreSQL database, but if the server is running on a Linux instance, the database may also use a local socket in addition to the port. The local socket is the best way to connect to a database because it eliminates the need to create a TCP connection during data transformation.

In this post, we will talk about how to change the default PostgreSQL port so that you can create as many databases as you want.

What is Postgres Database?

Postgres is an open-sourced database that we also know as PostgreSQL. It is a relational, enterprise-level, and advanced database that supports both SQL and NoSQL querying, such as JSON. Postgress has been around for almost 3 decades because of its stability in storing a huge amount of data for different organizations. Developers use Postgress for creating mobile, web applications, as well as for analytic applications.

In 1986, the University of California started the Postgres project for the first time, but initially, the project was known as POSTGRES. During that time, the project was designed to add minimal features that would support different kinds of data. In 1996, PostgreSQL demonstrated that it is up for support rational data queries. Since then, it has become famous for use in Windows, Mac, Solaris, etc., computer systems.

Postgres supports programming languages like Python, Java, Ruby, Node.js, C#, C++, C, etc. And it offers features like table inheritance, Multi-version concurrency control (MVCC), foreign key referential integrity, user-defined data types, and more. Now, to get the most out of Postgres, you will have to edit its configuration file where you can define your own data type as well as functional languages and index types. And that postgresql.conf File will also allow you to modify the postgres port for extra security purposes.

About Configuring the postgresql.conf File-

To connect to a PostgreSQL database server from a remote system, the only thing you can do is use the TCP connection. It uses the local socket that comes with higher latency but has limitations on the network bandwidth usage. To use the local socket or TCP connections, you should configure the PostgreSQL Server first. And to configure the server, you will have to edit the postgresql.conf file. You will have to find out the exact location of the file that depends on the operating system and PostgreSQL version. If you are running the Linux system, you will have to run a command that will help you find the file:

locate postgresql.conf

/etc/postgresql/9.5/main/postgresql.conf

The server’s version is added to the file’s path here, and you must ensure the path before opening the file. The Windows system displays the path as C:Program FilesPostgreSQL9.5data, and you must always look for the version. However, if you are using a Linux distribution, the following command should be used to open the configuration file:

vi /etc/postgresql/9.5/main/postgresql.conf

Using the unix_socket_directory feature, you can configure the local socket on Linux, and it will display the path of the filesystem and the possible location of the socket in the directory. To create the socket on a particular file system path, specify a directory that is usually in /var/run/postgresql/most of the time. The socket will be added to this directory when you commence the server following the time. You can either remove or add (#) to the following line to disable socket access:

unix_socket_directory= /var/run/postgresql/

Now, restart the server, and the changes will be applied:

service postgresql restart

But these steps are for configuring Postgres. If you want to change the PostgreSQL Port Number, follow the next method.

How to Change the PostgreSQL Port Number?

Surround SCM provides a default port number of 5432 after the installation of PostgreSQL. PostgreSQL will not work correctly if the port number is changed during installation. If another application uses the same port after installation, you can change the port number. Here is how you change the PostgreSQL port number:

  1. First, stop the Surround SCM Server if it is currently running.
  2. And you should also stop the PostgreSQL service to change the port number if it is currently running.
  3. Open the postgresql configuration file in a text editor. Its file location is possibly C:Program FilesPostgreSQLversion > data
  4. In the Connections and Authentication sector of the file, you can change the port number from 5432 to anything else you want.
  5. Click on File > Save and save the new number.
  6. Click on Windows Start.
  7. Type Run in the search box and launch the programme.
  8. Enter regedit in the run box and press Enter.
  9. The Windows Registry Editor will open up
  10. Now find the SCM Server directory, which’s default location is MY Computer. Seapine SoftwareSurround SCM SCM Server HKEY_LOCAL_MACHINESOFTWARES
  11. Then click on the DBPort registry.
  12. Click on Edit > Modify.
  13. Do you remember the new port number you set earlier? You will need to combine it with the value data.
  14. Press OK.
  15. Restart PostgreSQL service and the Surround SCM Server.

Conclusion

That was all about changing the default PostgreSQL port, but managing your PostgreSQL database is a much bigger topic. To connect to your PostgreSQL database using the default port, you’ll need to use some complex commands in your text editor. Check out our other relevant articles if you want to know how to manage a PostgreSQL database using the default Postgres port.

LEAVE A REPLY

Please enter your comment!
Please enter your name here