diff -ur postgresql-14.0.orig/src/bin/pg_upgrade/option.c postgresql-14.0/src/bin/pg_upgrade/option.c --- postgresql-14.0.orig/src/bin/pg_upgrade/option.c 2021-11-01 14:54:18.782057697 +0100 +++ postgresql-14.0/src/bin/pg_upgrade/option.c 2021-11-01 14:54:35.649100699 +0100 @@ -476,8 +476,14 @@ */ if (GET_MAJOR_VERSION(cluster->major_version) >= 901) { - if (!live_check) + if (!live_check) { cluster->sockdir = user_opts.socketdir; +#ifndef UNIX_PATH_MAX +#define UNIX_PATH_MAX 108 +#endif + if (strlen(cluster->sockdir) >= UNIX_PATH_MAX - sizeof(".s.PGSQL.50432")) + strcpy(cluster->sockdir, "/tmp"); /* fall back to tmp */ + } else { /* diff -ur postgresql-14.0.orig/src/include/pg_config_manual.h postgresql-14.0/src/include/pg_config_manual.h --- postgresql-14.0.orig/src/include/pg_config_manual.h 2021-11-01 14:54:18.575057170 +0100 +++ postgresql-14.0/src/include/pg_config_manual.h 2021-11-01 14:54:35.767101001 +0100 @@ -207,7 +207,7 @@ * support them yet. */ #ifndef WIN32 -#define DEFAULT_PGSOCKET_DIR "/tmp" +#define DEFAULT_PGSOCKET_DIR "/var/run/postgresql" #else #define DEFAULT_PGSOCKET_DIR "" #endif