I just installed wordpress and wanted to change the permlinks
I changed it to the postname but since then every page I create is instantly 404
When you change your permalink struture, WordPress (or you) needs to update your .htaccess file. If the file isn't writable to WordPress, you will see an error message at the bottom of the permalinks page in the dashboard after you click the update button -and you will get 404 errors just as you describe.
If the file is writable and there is no error, then you need to make sure that mod_rewrite is installed and operating correctly on your server, and that the AllowOverride and FollowSymlinks directives have been properly added to your site configuration.
If you are using a Windows IIS web server, then .htaccess doesn't apply at all, and permalinks take a little bit of a different turn.
Reference material: Using Permalinks