How to fix postgresql – ‘could not create shared memory segment: Invalid argument (shmget) ‘ error?

I recently updated my Postgresql’s ‘max_connections’ to 450 ( in postgresql.conf) which makes my postgresql server to fail during start-up :

FATAL: could not create shared memory segment: Invalid argument
DETAIL: Failed system call was shmget(key=5432001, size=35274752, 03600).
HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded your kernel's SHMMAX parameter. You can ...currently 454).
If the request size is already small, it's possible that it is less than your kernel's SHMMIN parameter, in which case raising the reque...s called for.
The PostgreSQL documentation contains more information about shared memory configuration.

This is because of your shared memory.

1) Check your maximum shared memory :
$ sudo cat /proc/sys/kernel/shmmax

You need to increase the shared memory to fix this.

2) To fix it temporarily, run this command :
$ sudo sysctl -w kernel.shmmax=134217728

3) To fix this permenantly, set this in your configuration:
$ sudo vi /etc/sysctl.conf
kernel.shmmax = 134217728

4) Now start your pgsql server, It will work.