Buffer Overflow Works Locally But Not Remotely

So I made a simple buffer overflow challenge and attempted to host it on a digitalocean droplet. The challenge source is below, and is compiled using gcc welcome.c -fno-stack-protector -no-pie -o welcome.

#include <unistd.h> #include <stdio.h>  int main(void) {     setvbuf(stdout, NULL, _IONBF, 0);     char name[25];     printf("whats your name? ");     gets(name);     printf("welcome to pwn, %s!\n", name);     return 0; }  void flag() {     char flag[50];     FILE* stream = fopen("flag.txt", "r");     fgets(flag, 50, stream);     printf("%s", flag); } 

Locally on the Docker the challenge is running on, I am able to use the exploit seen here. Trying to use it over the netcat connection though, it doesn’t work! All of the files I am using to host the challenge can be found here. Any help or other tips would be appreciated. I have spent a large part of the day confused about this.

Bonus question, why does the binary hang after completion on the remote server until the user hits enter? Maybe my setvbuf is incorrect? If someone could explain this that would be great! I am fairly new to this stuff.